Pick a Free OS

A look at System V initialization

Now, say you want httpd service started in the runlevel 3, you need to create a link to it from /etc/rc.d/init.d/httpd to /etc/rc.d/rc3.d. You can do this by created a symlink.

ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc3.d/S25httpd

Similarly create the symlink for killing the service here. But this is not a very easy way of managing your services. Red Hat provides a better tool that you can use to setup the rcx.d links. Under Red Hat you can use 'ntsysv' or 'chkconfig'. The tool 'ntsysv' brings up a menu where you can select or deselect a service to stop it from starting up. The command-line tool chkconfig can be used if more control is desired. This can be found in /sbin.

chkconfig --add service will add the service specified into the default runlevels. Other options are also available here.

--list [service] - Will list all the services and the runlevels they are active on. If a particular service is specified then the pertinent details for only that service are displayed.

chkconfig nfs off - Will remove the service from the runlevels that it is run in. A 'on' here will restore it to the runlevels.

chkconfig --level 35 ypserv on

The level switch is a very useful one in case you want to specify which runlevels you want to start the service from or turn it off if so required. Ypserv is now active on runlevels 3 and 5.

While adding services to runlevels, make sure that you starting them at the correct point. You should not start up Sendmail before your network has been initialized. NFS and YP require the services of Portmap so they should be assigned a number higher than Portmap is.

The rc.sysinit, rc and rc.local files are also of interest. The file rc.sysinit is the first to be executed. The filesystem checks and other important pre-initialization tasks are executed from this file. This then transfers control to the rc script. The rc script comes into play when changing runlevels and for basic initialization after which the scripts that are linked to the startup runlevel are executed. The file rc.local is executed at the very end of the boot process, after all the services have been started. You can put any post-boot jobs in here. This is a good place for your hdparm settings so that they're set at every boot.

SuSE has a slightly different setup. SuSE places the service scripts in the directory /sbin/init.d and the various runlevel directories are created under this directory. Also, instead of rc.sysinit, the boot process starts from the script /sbin/init.d/boot. Other than these differences, the basic structure is the same.