Runlevel笔记:修订间差异

来自三线的随记
无编辑摘要
无编辑摘要
第28行: 第28行:
number, and run 'update-rc.d script defaults' to reorder the scripts
number, and run 'update-rc.d script defaults' to reorder the scripts
according to dependencies.
according to dependencies.
A warning about the current runlevels
A warning about the current runlevels
being enabled not matching the LSB header in the init.d script will be
being enabled not matching the LSB header in the init.d script will be
printed. To re-enable the service, rename the script back to its
printed.
 
To re-enable the service, rename the script back to its
original name beginning with 'S' and run update-rc.d again.
original name beginning with 'S' and run update-rc.d again.
</blockquote>
</blockquote>

2018年11月13日 (二) 00:54的版本

简介

运行级别Runlevel)指的是Unix或者Linux等类Unix操作系统下不同的运行模式。运行级别通常分为 7 等,分别是从 0 到 6 ,但如果必要的话也可以更多。

例如在大多数Linux操作系统下一共有如下7个典型的运行级别:

  • 0 停机,关机
  • 1 单用户,无网络连接,不运行守护进程,不允许非超级用户登录
  • 2 多用户,无网络连接,不运行守护进程
  • 3 多用户,正常启动系统
  • 4 用户自定义
  • 5 多用户,带图形界面
  • 6 重启


/etc/init.d 和 /etc/rc*.d 那些事

1. /etc/rc*.d ----> The scripts are all symbolic links whose targets are located in /etc/init.d/ 
2. /etc/rc0.d ---->

Generally it is not necessary to alter the scripts in this directory.

Their purpose is to stop all services and to make the system ready

for shutdown.

3. /etc/rc1.d ----->

Generally it is not necessary to alter the scripts in this directory.

Their purpose is to stop all services and thus to put the system in

single-user mode.

4. /etc/rc2/3/4/5.d ----->

To disable a service in this runlevel, rename its script in this

directory so that the new name begins with a 'K' and a two-digit number, and run 'update-rc.d script defaults' to reorder the scripts according to dependencies.

A warning about the current runlevels being enabled not matching the LSB header in the init.d script will be printed.

To re-enable the service, rename the script back to its original name beginning with 'S' and run update-rc.d again.

5. /etc/rc6.d ----->

Generally it is not necessary to alter the scripts in this directory.

Their purpose is to stop all services and to make the system ready for reboot.

6. /etc/rcS.d ----->

The scripts in this directory whose names begin with an 'S' are

executed once when booting the system, even when booting directly into single user mode.

To disable a script in this directory, rename it so that it begins with a 'K' and run 'update-rc.d script defaults' to update the order using the script dependencies.