When Linux begins to boot with its kernel, it first runs the /sbin/init program, which does some system checks, such as verifying the integrity of the file systems, and starts vital programs needed for the operating system to function properly. It then inspects the /etc/inittab file to determine Linux's overall mode of operation or runlevel. A listing of valid runlevels in Debian Linux can be seen in the following table:
| 0 | System Halt |
| 1 | Single user |
| 2 | Full multi-user mode (Default) |
| 3-5 | Same as 2 |
| 6 | System Reboot |
Based on the selected runlevel, the init process then executes startup scripts located in subdirectories of the /etc/rc.d directory. Scripts used for runlevels 0 to 6 are located in subdirectories /etc/rc.d/rc0.d through /etc/rc.d/rc6.d, respectively. Here is a sample directory listing of the scripts in the /etc/rc.d/rc5.d directory:
lrwxrwxrwx 1 root root 19 2008-08-07 16:02 K25Bluetooth -> ../init.d/bluetooth
lrwxrwxrwx 1 root root 13 2008-08-07 16:01 K95gdm -> ../init.d/gdm
lrwxrwxrwx 1 root root 18 2008-10-08 16:53 S10sysklogd -> ../init.d/sysklogd
lrwxrwxrwx 1 root root 15 2008-10-08 15:04 S11klogd -> ../init.d/klogd
As you can see, each filename in these directories either starts with an "S" which signifies the script should be run at startup, or a "K", which means the script should be run when the system is shutting down. If a script isn't there, it won't be run. Most Linux packages place their startup script in the /etc/init.d directory and place symbolic links (pointers) to this script in the appropriate subdirectory of /etc/rc.d. This makes file management a lot easier. The number that follows the "K" or "S" specifies the position in which the scripts should be run in ascending order. In our example, sysklogd with a value 10 will be started before klogd with a value of 11.
In Debian Linux you can use the "update-rc.d" command or you can use "rcconf" utility or install "sysvconfig" utility to configure services and scripts running in different runlevels.
To read more about this subject visit the following pages: