4.3.4 About Service Scripts

The /etc/init.d directory contains the scripts that are used to start, stop, or otherwise control the operation of system services. When the system changes run level, init, under the control of the /etc/init/rc.conf file, calls the /etc/rc script to start the services that are required for the new run level and to stop any currently running services that are not required.

For each run level N, there is an /etc/rcN.d directory that contains the scripts that init uses to start and stop services. For example, /etc/rc3.d is the directory for run level 3. Each script in an /etc/rcN.d directory is actually a symbolic link to a script in /etc/init.d. Using symbolic links allows you to reconfigure run levels without affecting the scripts that the symbolic links reference.

The name of each symbolic link begins with either K (for kill) or S (for start), followed by a sequence number that indicates the order in which init should kill or start the services. init first stops each of the K* services in the order of their sequence numbers by executing each K script with the argument stop. init then starts each of the S* services in the order of their sequence numbers by executing each S script with the argument start. If symbolic links have the same sequence number, init stops or starts them in alphabetic order.


The entries for init.d, rc, rc.local, rc.sysinit, and rcN.d in /etc are actually symbolic links to entries in the /etc/rc.d directory. These links ensure compatibility with UNIX System V (SysV).

To customize service initialization, you can add scripts to /etc/init.d and create symbolic links to these scripts in the /etc/rcN.d directories, naming the links with an initial K or S according to whether init should stop or start the service in each run level N.

Alternatively, you can add commands to the /etc/rc.local script to start services or initialize devices.

For more information on writing SysV init scripts, see /usr/share/doc/initscripts*/sysvinitfiles.