Update-rc.d && rc.local管理Ubuntu的开机启动


前言

虽然是原创,毕竟自己对Ubuntu的开机启动研究了整整两天,期间看鸟哥linux私房菜、研究/etc/init.d/下shell源码等等,但是不可否认看了很多国内国外的文章,最终搞定也是基于一篇不错的博客文章,这里首先进行推荐:通过update-rc.d管理ubuntu开机启动   接下来,我会按照参考博客内容记录一些自己的收获(测试环境ubuntu10.04 && ubuntu12.04)

Ubuntu系统运行级别

  • 0 系统停机状态
  • 1 单用户或系统维护状态
  • 2~5 多用户状态
  • 6 重新启动

update-rc.d概要

Linux services can be started, stopped and reload with the use of scripts stocked(贮存) in/etc/init.d/. However, during start up or when changing runlevel, those scripts are searched in /etc/rcX.d/ where X is the runlever number(可以用runlevel命令查看系统默认的runlevel). This tutorial will explain how one can activate(激活), disactivate or modifu a service start up. When installing a new service under debian, the default is to enable it. So for instance, if you just installed apache2 package, after you installed it, apache service will be started and so will it be upon the next reboots. If you do not use apache all the time, you might want to disable this service from starting up upon boot up and simply start it manually when you actually need it by running this command:   sudo  /etc/init.d/apache2 start   You could either disable this service on boot up by removing any symbolic links in /etc/rcX.d/SYYapache2 or by using update-rc.d.The advantage of using update-rc.d is that is will take care of removing/adding any required links to /etc/init.d automatically.Taking apache2 as an example.     As you can see, for runlevels 0, 1 and 6 there is a K at the begining of the link, for runlevels 2, 3, 4 and 5, there is a S. Those two letters stands for Kill and Start.
Removing A Service If you want to totally disable apache2 service by hand, you would need to delete every single link in /etc/rcX.d/. Using update-rc.d it is a simple as : update-rc.d  [-f] servicename remove  
  • 1
  • 2
  • 3
  • 下一页

相关内容