Ubuntu14.04设置开机自启动脚本
方法一、编辑rc.loacl脚本
Ubuntu开机之后会执行/etc/rc.local文件中的脚本,所以我们可以直接在/etc/rc.local中添加启动脚本。在 exit 0 前面添加好脚本代码,如:
!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing. echo "hello start up script!" > /home/sc/Desktop/mystart.txt exit
重启后可以在桌面上看到生成的mystart.txt文件。
方法二、添加一个Ubuntu的开机启动服务
如果要添加为开机启动执行的脚本文件,可先将脚本复制或者软连接到/etc/init.d/目录下,然后用:update-rc.d xxx defaults NN 命令(NN为启动顺序),将脚本添加到初始化执行的队列中去。
#!/bin/bash
# command content
echo "hello start up script!" > /home/sc/Desktop/mystart.txt
exit
2) 将脚本放置到启动目录/etc/init.d下
sudo mv test.sh /etc/init.d/
cd /etc/init.d/
sudo chmod 755 test.sh
4) 将脚本添加到启动脚本中
sudo update-rc.d test.sh defaults
其中数字90是脚本启动的顺序号,数字越大表示执行的越晚,按照自己的需要相应修改即可。

重启后可以在桌面上看到生成的mystart.txt文件。
sudo update-rc.d -f test.sh remove

方法三、桌面环境下设置开机自启动
从Xfce桌面菜单中选择"Settings Manager"(设置管理器)。在"Settings"(设置)窗口中,点击"Session and Startup"(会话和启动)图标。




gnome-terminal -x /home/sc/Desktop/test
gnome-terminal打开一个新的终端,-x参数后面的内容是要执行的命令。重新启动后可以看到gnome终端模拟器中打印出Hello world!
如果执行完后一闪而过,一种方法是修改terminal的配置,选择Edit→Profile Preferences→Title and Command,里面有一项When command exits,选为Hold the terminal open就可以了。
Ubuntu14.04设置开机自启动脚本的更多相关文章
- ubuntu14.04 设置开机自启动脚本
方法1.将脚本放入/etc/rc.local文件中. 方法2.添加一个ubuntu的开机启动服务 分为以下几个步骤: 1)新建一个脚本文件 new_services.sh #!/bin/bash # ...
- Ubuntu14.04设置开机自启动程序
启动应用程序可以帮助我们选择开机启动项.但是在Ubuntu14.04通过Dash输入startup 找不到启动应用程序了,可以通过在控制台输入以下内容: gnome-session-propertie ...
- Ubuntu14.04设置开机启动脚本(转)
原文:https://www.magentonotes.com/ubuntu-config-autostart-shell-script.html 方法一:将脚本添加到文件/etc/rc.local ...
- ubuntu-18.04 设置开机启动脚本
ubuntu-18.04 设置开机启动脚本 参阅下列链接 https://askubuntu.com/questions/886620/how-can-i-execute-command-on-sta ...
- ubuntu-18.04 设置开机启动脚本-亲测有效
ubuntu-18.04不能像ubuntu14一样通过编辑rc.local来设置开机启动脚本,通过下列简单设置后,可以使rc.local重新发挥作用. 2.将下列内容复制进rc-local.servi ...
- Ubuntu 18.04 设置开机启动脚本 rc.local systemd
ubuntu18.04不再使用initd管理系统,改用systemd. ubuntu-18.04不能像ubuntu14一样通过编辑rc.local来设置开机启动脚本,通过下列简单设置后,可以使rc.l ...
- Ubuntu-18.04设置开机启动脚本
参考:https://www.cnblogs.com/defifind/p/9285456.html http://www.cnblogs.com/airdot/p/9688530.html s ...
- centos设置开机自启动脚本
1.新建脚本文件 我这里是为了设置开机自动设置ipv6隧道,所以命名为ipv6tunnel.sh ifconfig sit0 up ifconfig sit0 inet6 tunnel ::66.22 ...
- Ubuntu 16.04设置开机启动脚本的方法
需求:公司卡片机容量太小,只有100G,由于使用的人比较的多,开机使用后有时候就会出现磁盘空间占满数据写不进去的情况,影响工作进度,而且每次使用完都得关掉卡片机,所以就有必要写个清理磁盘的脚本,当卡片 ...
随机推荐
- [Android Pro] ESP和EBP 栈顶指针和栈底指针
cp: http://blog.csdn.net/hutao1101175783/article/details/40128587 (1)ESP:栈指针寄存器(extended stack poin ...
- [转]Sphinx+Mysql+中文分词安装-实现中文全文搜索
From : http://blog.csdn.net/lgm252008/article/details/5373436 1.什么是SphinxSphinx 是一个在GPLv2 下发布的一个全文检索 ...
- pchar,pwidechar,pansichar作为返回参数时内存访问错误
function Test:pachr: var str: string; begin str := 'Test Char'; result:=pchar(str); end; 上面的Te ...
- go语言之进阶篇 channel介绍
1.channel介绍 和map类似,channel也一个对应make创建的底层数据结构的引用. 当我们复制一个channel或用于函数参数传递时,我们只是拷贝了一个channel引用,因此调用者何被 ...
- EntityFramework6 快速入门教程【转】
https://www.cnblogs.com/wujingtao/p/5401113.html 不得不说EF在国内实在是太小众,相关的技术文章真实屈指可数,而且很多文章都很旧了,里面使用的版本跟如今 ...
- 如何使用chrome自带的Javascript调试工具 【转】
http://zhangyongbluesky.blog.163.com/blog/static/1831941620113155739840/ 将写好的Javascript代码用chrome打开. ...
- [leetcode]Substring with Concatenation of All Words @ Python
原题地址:https://oj.leetcode.com/problems/substring-with-concatenation-of-all-words/ 题意: You are given a ...
- 读书笔记,《Java 8实战》第五章,使用流
本章我们将会了解到关于Stream API的很多操作,这些操作能够完成很多复杂的查询,比如,比如筛选,切片,映射,查找,匹配和规约, 第一节,筛选和切片 首先我们来看看用谓词来选择流动的元素,主 ...
- Set Matrix Zeroes leetcode java
题目: Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. cl ...
- JavaScript Math和Number对象研究
1. Math 对象 1.1 介绍 Math 对象,是数学对象,提供对数据的数学计算,如:获取绝对值.向上取整等.无构造函数,无法被初始化,只提供静态属性和方法. 1.2 构造函数 无 : ...