Linux Training : 10. chkconfig


chkconfig is the command line tool to setup init scripts for different runlevels.

chkconfig allows for quick runlevel editing.

While it is certainly possible to manually make symlinks to set start and stop scripts for each process for each runlevel, chkconfig is far more efficient.
chkconfig --list will show all the init scripts and their status for each runlevel. chkconfig --level 3 httpd on will set httpd to be on for runlevel 3.
chkconfig --add foo will add the service foo for management by chkconfig. This requires the /etc/init.d/foo script contain a pair of commented lines near the top that are used by chkconfig. For instance, the network init script begins

#! /bin/bash
# network       Bring up/down networking
# chkconfig: 2345 10 90
# description: Activates/Deactivates all network interfaces configured to \
#              start at boot time.

The script line chkconfig: 2345 10 90 tells chkconfig it starts in runlevel 2,3,4 and 5 with priority 10 and stops with priority 90. The description line is continued with the trailing "\".

chkconfig exercise
  1. Use chkconfig to find all services that start in runlevel 1.
  2. Turn on postfix for runlevel 3 and 5 only
  3. Verify the levels postfix runs in.
  4. Turn off postfix for all levels