When the system starts, and after the kernel has configured everything and mounted the root file system, it executes /sbin/init[28]. init is the father of all of the system's processes and is responsible for taking the system to the desired run level. We will look at runlevels later on (see Section 2, “Runlevels”).
The init configuration file is
called /etc/inittab
and has its own manual
page (inittab(5)), so we will only
document a few of the possible configuration values.
The first line which should be the focus of your attention is this one:
si::sysinit:/etc/rc.d/rc.sysinit
This line tells
init that /etc/rc.d/rc.sysinit is to be
run once the system has been initialized (si
stands for System Init). To
determine the default runlevel, init will then look for the
line containing the initdefault
keyword:
id:5:initdefault:
In this case, init knows that the default runlevel is 5. It also knows that to enter level 5, it must run the following command:
l5:5:wait:/etc/rc.d/rc 5
As you can see, the syntax for each runlevel is similar.
init is also responsible for
restarting (respawn
) some programs which cannot
be started by any other process. For example, each of the login
programs which run on the six virtual consoles are started by
init[29]. The second
virtual console is identified this way:
2:2345:respawn:/sbin/mingetty tty2
[28] Which is why putting
/sbin
on a file system other than the
root one would be a very bad idea. The kernel has not
mounted any other partitions at this point, and therefore would
not be able to find
/sbin/init.
[29] If you do not want six virtual consoles, you may add or remove some by modifying this file. If you wish to increase the number of consoles, you can have up to a maximum of 64. But don't forget that X also runs on a virtual console, so leave at least one console free for X.