There are several different init systems for Linux. The main ones are SysVinit (the traditional one), Upstart (Ubuntu's replacement), and SystemD (pushed by Fedora and Gnome). The directories /etc/init.d
and /etc/rc?.d
are used by SysVinit. The book may be mentioning them with regards to Ubuntu because the information is a bit dated (Ubuntu used to use SysVinit like everyone else) or because those directories still exist for compatibility.
/etc/init.d
contains a bunch of scripts, each containing instructions to start and stop a service. Some of these services need to be started at boot time; others need to be started in multiuser mode but not in single-user maintenance mode; and it's possible to define different modes with different sets of desired services. SysVinit manages this through runlevels. The directory /etc/rc$N.d
contain the scripts to run when entering runlevel N (/etc/rc$N.d/S*
) and the scripts to run when leaving runlevel N (/etc/rc$N.d/K*
). Because many runlevels have scripts in common, rather than store a copy of the scripts for each runlevel, the scripts are all stored in a single location /etc/init.d
, and the runlevel-specific directories /etc/rc?.d
contain symbolic links. Furthermore the names of the symbolic links indicate whether the service is to be started (S*
) or stopped (killed, K*
) in that runlevel, and a numeric prefix is used to control the order in which the scripts are executed.
The script responsible for traversing /etc/rc$N.d
is /etc/init.d/rc
(on pre-Upstart Ubuntu and on Debian; locations may vary on other Linux distributions).