runlevel和init命令

-- TOC --

runlevel是SysV系统的概念,用于控制系统启动和关停,现在是systemd的天下,貌似这个概念已经无用了。

下面这段来自 man runlevel

"Runlevels" are an obsolete way to start and stop groups of services used in SysV init. systemd provides a compatibility layer that maps runlevels to targets, and associated binaries like runlevel. Nevertheless, only one runlevel can be "active" at a given time, while systemd can activate multiple targets concurrently, so the mapping to runlevels is confusing and only approximate. Runlevels should not be used in new code, and are mostly useful as a shorthand way to refer the matching systemd targets in kernel boot parameters.

以前的SysV,/etc/rc.d下面有7个名为rcN.d的目录,对应系统的7个runlevel。在启动的时候,根据runlevel的值,来确定执行哪个目录中的脚本。

虽然如此,runlevelinit这两个命令还是能够使用。

$ runlevel
N 5

执行 init 0,关机!

执行 init 3,关闭X Window,进入文本模式!

执行 init 6,重启!

我估计可能更多的还是为了向后兼容吧!

busybox做的启动U盘,起来后运行runlevel,显示unknown!

本文链接:https://cs.pynote.net/sf/linux/shell/202111153/

-- EOF --

-- MORE --