next up previous contents index
Next: Using chkconfig Up: System Services Previous: System Services   Contents   Index

Symbolic Links

You can create a symbolic link to a service so that it starts or stops at different run levels. Symbolic links do all of the database work required to know which servers to start and which ones to stop.

If you go into the /etc/rc.d/ directory you will find a lot of subdirectories and some files. It should look something like this:

bash# ls -l
total 60
drwxr-xr-x    2 root     root         4096 Jan 22 16:54 init.d
-rwxr-xr-x    1 root     root         3047 Feb  7  2001 rc
drwxr-xr-x    2 root     root         4096 Oct 29  2001 rc0.d
drwxr-xr-x    2 root     root         4096 Oct 29  2001 rc1.d
drwxr-xr-x    2 root     root         4096 Oct 29  2001 rc2.d
drwxr-xr-x    2 root     root         4096 May 21 11:31 rc3.d
drwxr-xr-x    2 root     root         4096 May 21 11:31 rc4.d
drwxr-xr-x    2 root     root         4096 May 21 11:31 rc5.d
drwxr-xr-x    2 root     root         4096 Oct 29  2001 rc6.d
-rwxr-xr-x    1 root     root          962 Jan 29  2001 rc.local
-rwxr-xr-x    1 root     root        18851 Apr  7  2001 rc.sysinit

The files rc, rc.local, and rc.sysinit are programs that help with runlevel changes.

rc starts and stops services as the runlevel changes. rc.local runs after all of the rest of the initialization scripts. If you want something started after everything else, you can put it on the end of this file. rc.sysinit runs once at boot time and starts getting everything set up the way it should be.

OK, now for the symbolic links. If you go into one of the directories with a digit in them such as rc5.d/ you will be able to see what happens when this runlevel is started.

The files in each of these directory are links that point to the real files in the /etc/rc.d/init.d/ directory. The links either start with K or S. K stands for Kill and S for Start. After the letter comes a two digit number. The letters and numbers are sorted when the runlevel is started and each service that has a K in front is killed if it is running and everything with an S in front is started if it is not already running.

If you wanted to change the order in which something is started or stopped you could change the two digit number to something else. Lower numbers come before higher numbers because they are alphabetically sorted.

To create a link you can use the ln command. If you were in the /etc/rc.d/rc5.d/ directory and wanted the httpd server to start at about 85 you would type this:

bash# ln -s ../init.d/httpd S85httpd

This will create a link called S85httpd that points to the real file found at /etc/rc.d/init.d/httpd.


next up previous contents index
Next: Using chkconfig Up: System Services Previous: System Services   Contents   Index
Joseph Colton 2002-09-24