Yes... that's a perfectly valid question, and one that
would be of interest to other people.
Here's the skinny...
(1) To quote
man init:
Quote:
A runlevel is a software configuration of the system which allows only a selected group of processes to exist. The processes spawned by init for each of these runlevels are defined in the /etc/inittab file. init can be in one of eight runlevels: 0?6 and S or s. The runlevel is changed by having a privileged user run telinit, which sends appropriate signals to init, telling it which runlevel to change to.
Runlevels 0, 1, and 6 are reserved. Runlevel 0 is used to halt the system, runlevel 6 is used to reboot the system, and runlevel 1 is used to get the system down into single user mode. Runlevel S is not really meant to be used directly, but more for the scripts that are executed when entering runlevel 1. For more information on this, see the man-pages for shutdown(8) and inittab(5).
Runlevels 7-9 are also valid, though not really documented. This is because "traditional" Unix variants don't use them. In case you?re curious, runlevels S and s are in fact the same. Internally they are aliases for the same runlevel.
|
So, the system "shuts down" by "switching to runlevel 0." It starts-up by switching to the default runlevel specified in
/etc/inittab, usually "5."
(Incidentally, Windows has this concept too ... "safe mode" is a runlevel.)
(2) If we look at
/etc/inittab, we see that it executes the
/etc/rc.d/rc script with a single parameter that specifies the runlevel.
(3) If we look at
that script (there are no secrets in Linux...), we see that it searches for files in
/etc/rc.d/rcn.d, where
n is the chosen runlevel, looking first for files that start with "K"(ill) , then for files that start with "S"(tart). It executes these files with a parameter of "stop" or "start," respectively,
and it processes the files in ascending alphabetic order.
(4) Pressing the point further, if we look in any one of the
/etc/rc.d/rcn.d directories, we see files like, say, "
S55cups" or "
K87irqbalance." They start with either "S" or "K", as expected, and the two digits clearly must be intended to place them in a predictable "alphabetic order." We also observe, if we do
ls -l, that each of these files are in fact a
symbolic link (symlinks) ... a reference to a file that actually exists somewhere else.
(5) That "somewhere else" is
/etc/init.d and here we find all of the scripts. A script may be "pointed to" by many different symlinks in these various directories.
This, then, explains what most of the messages that we see at startup time actually come from. When we see "starting cups [ok]" ...
- init is "switching to" runlevel 5.
- The /etc/inittab file has told it to run rc 5.
- The rc script is trolling through the "Snn..." symlinks one by one, calling each one by means of its action subroutine (/etc/init.d/functions), which will check the return value and print either "[ok]" or "[FAILED]."
- The /etc/init.d/cups start command apparently returned an "okay" return-code.