debian命令行下的runlevel探索

今天配置uwsgi时想自己写一个自启动脚本,就去了解了以下Runlevel,下面是Debian官方的解释

Linux runlevel controls what processes / services are started automatically by the system (or by Init to be more exact). The runlevel is a digit from 0 to 6 or the letter S. Runlevels 0, 6 and S are reserved for shutdown, reboot and single user mode respectively. Automation is the keyword here because any of the services can be started later manually at any runlevel.

Debian defines seven runlevels (0-6).

0 (halt the system) 1 (single-user / minimal mode), 2 through 5 (multiuser modes), and 6 (reboot the system).

解释一下,你在/etc目录下会发现几个文件夹,比如/etc/rcn.d/,n可以是0~6,系统处于不同的runlevel时就会运行对应文件夹下的命令,而这些命令其实是/etc/init.d/下面文件的快捷方式。如果你想让一个程序开机启动,只需把命令放入对应的文件夹即可。官方说的在Debian下,runlevel2~5是相同的,可是我挨着试了一遍,发现在无图形界面的Debain下其实运行在RunLevel2,欢迎大家指正。

1,809 views, since 2011-11-13