All files related to system startup are located in the directory /etc/rc.d. Here is the list of the files:
$ ls /etc/rc.d init.d/ rc.local* rc0.d/ rc2.d/ rc4.d/ rc6.d/ rc* rc.sysinit* rc1.d/ rc3.d/ rc5.d/ |
Then the rc script is run, with the desired runlevel as an argument. As we have seen, the runlevel is a simple integer, and for each runlevel <x> defined, there must be a corresponding rc<x>.d directory. In a typical Mandrake Linux installation, you might therefore see that 6 runlevels are defined:
0: complete machine stop;
1: single-user mode; to be used in the event of major problems or system recovery;
2: multi-user mode, without networking;
3: Multi-user mode, but this time with networking;
4: unused;
5: like 3, but also launches the graphical login interface;
6: restart.
Let us look, for example, at the contents of directory rc5.d:
$ ls rc5.d K15postgresql@ K60atd@ S15netfs@ S60lpd@ S90xfs@ K20nfs@ K96pcmcia@ S20random@ S60nfs@ S99linuxconf@ K20rstatd@ S05apmd@ S30syslog@ S66yppasswdd@ S99local@ K20rusersd@ S10network@ S40crond@ S75keytable@ K20rwhod@ S11portmap@ S50inet@ S85gpm@ K30sendmail@ S12ypserv@ S55named@ S85httpd@ K35smb@ S13ypbind@ S55routed@ S85sound@ |
<S|K><order><service_name> |
When the system goes into a given runlevel, it starts by running the K links in order: rc looks where the link is pointing, then calls up the corresponding script with the single argument stop. Then it runs the S scripts, still using the same method, apart from the fact that the script is called with the argument start.
Thus, without mentioning all the scripts, we can see that when the system goes into runlevel 5, it first runs K15postgresql, i.e. /etc/rc.d/init.d/postgresql stop. Then K20nfs, then K20rstatd, until the last one; next, it runs all the S scripts: first S05apmd, which then calls /etc/rc.d/init.d/apmd start, and so on.
Armed with all this, you can create your own entire runlevel in a few minutes, or prevent a service starting or stopping by deleting the corresponding symbolic link (there are also interface programs for doing this, notably drakxservices and chkconfig; the former is a graphical program).