System V init, often shortened to SysV, is the traditional Unix-style way of starting a Linux system. Most large distributions have moved to systemd, but you will still meet SysV on older servers and some small distributions, and its ideas survive in command names.
Runlevels
A runlevel is a named state of the system, numbered 0 to 6. Each one says which services should run. The common meanings are:
0halt1single user mode, for maintenance6reboot
Levels 2 to 5 depend on the distribution. On Red Hat style systems, 3 is multi-user text mode and 5 adds a graphical login. Debian traditionally treats 2 to 5 the same, with 2 as the default.
The inittab file
SysV init reads /etc/inittab. Each entry has four fields separated by colons:
id:runlevels:action:processThis line sets the default runlevel to 3:
id:3:initdefault:Never set the default to 0 or 6, or the machine will shut down or reboot every time it starts.
Scripts and rc directories
Service scripts live in /etc/init.d. Each runlevel has a directory such as /etc/rc3.d (or /etc/rc.d/rc3.d) holding symbolic links to those scripts:
$ ls /etc/rc3.d
K01bluetooth S01rsyslog S02cron S03sshA name starting with K means the script is called with stop. A name starting with S means it is called with start. When entering a runlevel, the K links run first, then the S links. Traditionally the two digits set the order within each group, although some newer SysV setups work the order out from dependencies declared in the scripts.
Checking and changing runlevel
$ runlevel
N 3The first value is the previous runlevel, where N means there was none. The second is the current one. To switch, an administrator can run:
$ sudo telinit 1This stops services, so it can cut off your network session. Do not try it on a remote machine you care about.
On a systemd machine, runlevel and telinit may exist only as compatibility commands, and there may be no /etc/inittab.
Try it
Run runlevel, then list /etc/init.d and any rc*.d directory you have. Pick one S link and use ls -l to see which script it points to.
Check your understanding
System V Overview
All 5 sections ยท no timer
Unlimited retries
Questions from every section are combined into one assessment. Answer them all correctly to complete the article.
Your completion saves in this browser. Sign in to sync it to your account.