fedora20添加开机自动启动程序和添加sudo用户

来源:互联网 发布:mac版qq怎么远程 编辑:程序博客网 时间:2024/05/12 02:29

1./etc/rc.local其实是/etc/rc.d/rc.local的软连接,那么:


# cat /etc/rc.d/rc.local
#! /bin/sh

/usr/bin/offlineimap &
/usr/bin/echo "abdc" > /root/test-lili  &

--------

  chmod +x /etc/rc.d/rc.local
  ln -s /etc/rc.d/rc.local /etc/rc.local
2.重启机器
  查看/root下是不是多了个文件test-lili,并且offlineimap已经运行,说明我们的开机脚本已经运行了!

***

Note:

在写/etc/rc.d/rc.local文件时,

命令最好用上全路径名,同时可以写成后台运行,这样会加快开机速度。

--------------------------------------------

添加sudo用户

# echo "lijun ALL=(ALL)  ALL" >> /etc/sudoers.d/lijun

------------------

Ref:

http://blog.csdn.net/lingfong_cool/article/details/8861020

=============================================================

方法二:

cd /etc/init.dvi youshell.sh   #将youshell.sh修改为你自己的脚本名

编写自己的脚本后保存退出。在编写脚本的时候,请先加入以下注释

#add for chkconfig#chkconfig: 2345 70 30#description: the description of the shell   #关于脚本的简短描述#processname: servicename                    #第一个进程名,后边设置自启动的时候会用到

说明:
2345是指脚本的运行级别,即在2345这4种模式下都可以运行,234都是文本界面,5就是图形界面X
70是指脚本将来的启动顺序号,如果别的程序的启动顺序号比70小(比如44、45),则脚本需要等这些程序都启动以后才启动。
30是指系统关闭时,脚本的停止顺序号。

----

e.g:

cat youshell.sh

#! /bin/sh#add for chkconfig#chkconfig: 2345 70 30#description: the description of the shell#processname: servicename_li/usr/bin/offlineimap &

----


给脚本添加上可执行权限:

chmod +x youshell.sh

chkconfig --level 2345 youshell.sh on
-----------
Ok ! Success!

0 0