个人工具

“启动”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
/etc/rc2.d
第19行: 第19行:
  
 
即在 init 命令后跟一个参数,此参数是要切换到的运行级的运行级代号,如:用 init 0 命令关机;用 init 6 命令重新启动。
 
即在 init 命令后跟一个参数,此参数是要切换到的运行级的运行级代号,如:用 init 0 命令关机;用 init 6 命令重新启动。
 
==sysv-rc-conf ==
 
查看/修改不同运行级别的启动项,可以发现Ubuntu(其实是Debian)2-5之间的runlevel效果是一样的。
 
<pre>sudo apt-get install sysv-rc-conf </pre>
 
<pre>sudo sysv-rc-conf </pre>
 
  
 
==/etc/rc2.d==
 
==/etc/rc2.d==
第38行: 第33行:
 
<pre>sudo update-rc.d script defaults</pre>
 
<pre>sudo update-rc.d script defaults</pre>
 
可以禁用某个服务,不过比较麻烦,方便的方法是'''sysv-rc-conf'''。
 
可以禁用某个服务,不过比较麻烦,方便的方法是'''sysv-rc-conf'''。
 +
==runlevel下的增/删==
 +
===sysv-rc-conf ===
 +
查看/修改不同运行级别的启动项,可以发现Ubuntu(其实是Debian)2-5之间的runlevel效果是一样的。
 +
<pre>sudo apt-get install sysv-rc-conf </pre>
 +
<pre>sudo sysv-rc-conf </pre>
  
==update-rc.d==
+
===update-rc.d===
 
添加启动项,例如mysql
 
添加启动项,例如mysql
 
<pre>qii@ubuntu:/etc/rc2.d$ sudo update-rc.d mysql defaults  
 
<pre>qii@ubuntu:/etc/rc2.d$ sudo update-rc.d mysql defaults  
第65行: 第65行:
 
</pre>
 
</pre>
  
==rcconf==
+
===rcconf===
 
查看,修改当前运行级别的启动项
 
查看,修改当前运行级别的启动项
 
<pre>sudo apt-get install rcconf</pre>
 
<pre>sudo apt-get install rcconf</pre>
 
<pre>sudo rcconf</pre>
 
<pre>sudo rcconf</pre>
 
+
==autostart==
 
[[Category:系统]]
 
[[Category:系统]]

2010年8月1日 (日) 18:47的版本

Ubuntu 系统的启动流程、增/删启动项

init

Linux 内核启动 init ,init进程ID是1,是所有进程的父进程,所有进程由它控制。

/etc/event.d

Ubuntu 的启动由upstart控制,自9.10后不再使用/etc/event.d目录的配置文件,改为/etc/init。

runlevel

查看当前的运行级别,Ubuntu 桌面默认是2。

runlevel

Ubuntu 的系统运行级别:

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

切换运行级别,执行命令:

int [0123456Ss]

即在 init 命令后跟一个参数,此参数是要切换到的运行级的运行级代号,如:用 init 0 命令关机;用 init 6 命令重新启动。

/etc/rc2.d

该目录为runlevel=2环境(就是Ubuntu默认情况)的启动项

qii@ubuntu:/etc/rc2.d$ ls
README             S20nginx              S20xinetd      S50rsync      S90binfmt-support  S99grub-common
S19postgresql-8.4  S20speech-dispatcher  S25bluetooth   S50saned      S91apache2         S99ondemand
S20fancontrol      S20wicd               S50cups        S70dns-clean  S91lighttpd        S99rc.local
S20kerneloops      S20winbind            S50pulseaudio  S70pppd-dns   S99acpi-support

其中S表示启动,随后的数字表示启动的顺序。

手动的话将S重命名为K,运行

sudo update-rc.d script defaults

可以禁用某个服务,不过比较麻烦,方便的方法是sysv-rc-conf

runlevel下的增/删

sysv-rc-conf

查看/修改不同运行级别的启动项,可以发现Ubuntu(其实是Debian)2-5之间的runlevel效果是一样的。

sudo apt-get install sysv-rc-conf 
sudo sysv-rc-conf 

update-rc.d

添加启动项,例如mysql

qii@ubuntu:/etc/rc2.d$ sudo update-rc.d mysql defaults 
update-rc.d: warning: /etc/init.d/mysql missing LSB information
update-rc.d: see <http://wiki.debian.org/LSBInitScripts>
 Adding system startup for /etc/init.d/mysql ...
   /etc/rc0.d/K20mysql -> ../init.d/mysql
   /etc/rc1.d/K20mysql -> ../init.d/mysql
   /etc/rc6.d/K20mysql -> ../init.d/mysql
   /etc/rc2.d/S20mysql -> ../init.d/mysql
   /etc/rc3.d/S20mysql -> ../init.d/mysql
   /etc/rc4.d/S20mysql -> ../init.d/mysql
   /etc/rc5.d/S20mysql -> ../init.d/mysql

删除启动项

qii@ubuntu:/etc/rc2.d$ sudo update-rc.d -f mysql remove 
 Removing any system startup links for /etc/init.d/mysql ...
   /etc/rc0.d/K20mysql
   /etc/rc1.d/K20mysql
   /etc/rc2.d/S20mysql
   /etc/rc3.d/S20mysql
   /etc/rc4.d/S20mysql
   /etc/rc5.d/S20mysql
   /etc/rc6.d/K20mysql

rcconf

查看,修改当前运行级别的启动项

sudo apt-get install rcconf
sudo rcconf

autostart