Pick a Free OS

A look at System V initialization

2,3,4 and 5 can be customized to your liking. Red Hat, for example, uses runlevel 5 when starting the GUI after boot. Runlevel 2 is used to startup in multi-user without NFS. SuSE on the other hand, uses runlevel 2 for multi-user with network and runlevel 3 for the multi-user GUI startup. There's nothing stopping you from changing this setup to a custom configuration of your liking.

/etc/rc.d

The startup scripts and files are placed in the directory /etc/rc.d. Some distributions do divert and do things differently here. SuSE used /sbin/init.d instead. We'll first look at Red Hat and then look at the SuSE structure in this article.

Red Hat uses /etc/rc.d. Given below is the result of an "ls -p" in this directory.

init.d/ rc.local rc0.d/ rc2.d/ rc4.d/ rc6.d/

rc rc.sysinit rc1.d/ rc3.d/ rc5.d/

init.d is a very important directory as it holds the scripts for the various services. The scripts, which are simple shell scripts, generally offer some very useful functions that are given as command line arguments.

/etc/rc.d/init.d/httpd start

Common arguments that can be supplied are

start - Start the service

stop - Stop the service

restart - Stop the service and restart it.

status - Display information regarding the status of the service, whether it is running or not.

Now, enter any runlevel directory and do a "ls -l" there. You will see something like the extract below.

lrwxrwxrwx 1 root root 14 Jan 8 17:14 K80nscd -> ../init.d/nscd

lrwxrwxrwx 1 root root 16 Jan 8 17:14 K83ypbind -> ../init.d/ypbind

lrwxrwxrwx 1 root root 17 Jan 8 17:14 S10network -> ../init.d/network

lrwxrwxrwx 1 root root 17 Jan 8 17:14 S11portmap -> ../init.d/portmap

lrwxrwxrwx 1 root root 16 Jan 8 17:14 S12syslog -> ../init.d/syslog

You can now see that the contents of the runlevel directories are merely symlinks that point to the scripts in the init.d directory. You should also take note of the naming scheme of these symlinks.

Either an "S" or a "K" prefixes the link name followed by a two-digit number. The "S" means that the service is to be started when the system enters that runlevel whereas conversely "K" would mean that the service is to be stopped when the system changes from that runlevel. The two-digit number is also of significance. The number decides at what point in the boot process the service is to be started or killed. The services are started or killed in ascending order of the number provided.