This articles describes the Linux chkconfig configurations and how are these maintained in the /etc/rc.d/init.d scripts by Red Hat Linux.
Default runlevel Configuration
In Linux, init process is responsible to start other processes during boot. Which services to start depends on the current runlevel of the system. In Red Hat Linux, the default runlevel configuration is stored in /etc/inittab file as shown below.
# cat /etc/inittab # # inittab This file describes how the INIT process should set up # the system in a certain run-level. # # Author: Miquel van Smoorenburg, # Modified for RHS Linux by Marc Ewing and Donnie Barnes # # Default runlevel. The runlevels used by RHS are: # 0 - halt (Do NOT set initdefault to this) # 1 - Single user mode # 2 - Multiuser, without NFS (The same as 3, if you do not have networking) # 3 - Full multiuser mode # 4 - unused # 5 - X11 # 6 - reboot (Do NOT set initdefault to this) # id:3:initdefault: [ Here, Linux system is configured to start at runlevel 3 by default ] # System initialization. si::sysinit:/etc/rc.d/rc.sysinit And more...
/etc/rc.d/init.d Scripts
Init program uses the init scripts to start/stop the services. These scripts are present in /etc/rc.d /init.d folder.
# ls -l /etc/rc.d/init.d/
total 684
-rwxr-xr-x 1 root root 1566 Aug 1 2008 acpid
-rwxr-xr-x 1 root root 1441 Dec 18 2006 anacron
-rwxr-xr-x 1 root root 1429 Aug 22 2006 apmd
-rwxr-xr-x 1 root root 1176 Aug 23 2006 atd
-rwxr-xr-x 1 root root 3114 Dec 11 2008 auditd
-rwxr-xr-x 1 root root 2461 Dec 3 2008 autofs
And more...
Linux chkconfig Configurations
Every init script contains two commented lines starting with ‘chkconfig: ‘ and ‘description: ‘ at the beginning.
The line starting with ‘chkconfig: ‘ contains the default boot time startup and shutdown configuration of the service. The line starting with ‘description:’ contains the service description.
Let’s have a look at the sshd init script as an example.
# cat /etc/rc.d/init.d/sshd #!/bin/bash # # Init file for OpenSSH server daemon # # chkconfig: 2345 55 25 # description: OpenSSH server daemon # # processname: sshd # config: /etc/ssh/ssh_host_key # config: /etc/ssh/ssh_host_key.pub # config: /etc/ssh/ssh_random_seed # config: /etc/ssh/sshd_config # pidfile: /var/run/sshd.pid # source function library . /etc/rc.d/init.d/functions # pull in sysconfig settings [ -f /etc/sysconfig/sshd ] && . /etc/sysconfig/sshd RETVAL=0 prog="sshd" And more ...
You can notice that the ‘chkconfig:’ line contains three configuration values.
#chkconfig: 2345 55 25
The first value ’2345′ states the default runlevels at which the service should be started. In this case, the service is configured to start at runlevel 2,3,4 & 5.
The second value ’55′ states the start priority of the service. In this case the sshd service shall be started after starting all those services having start priority less than 55.
The third value ’25′ states the stop priority of the service. In this case the sshd service shall be stopped after stopping all those services having stop priority less than 25.
Let’s have a look at the default ‘chkconfig:’ configuration for iptables and kdump services.
# cat /etc/rc.d/init.d/sshd | grep chkconfig: # chkconfig: 2345 55 25 # cat /etc/rc.d/init.d/iptables | grep chkconfig: # chkconfig: 35 08 92 # cat /etc/rc.d/init.d/kdump | grep chkconfig: # chkconfig: 235 20 80
iptables service is configured to start at runlevel 3 and 5 with start priority 8 and stop priority 92. Which means, start early and terminate late.
kdump is configured to start at runlevel 2, 3 and 5 with start priority 20 and stop priority 80.
If Linux system is booted at runlevel 3 then these services (ssh, iptables, kdump) shall be started automatically in the following order:
- iptables (start priority: 08)
- kdump (start priority: 20)
- sshd (start priority: 55)
If Linux system is booted at runlevel 2 then the startup order would be:
- iptables service shall not start as it is disabled at runlevel 2
- kdump (start priority: 20)
- sshd (start priority: 55)
And on shutdown, these service shall be stopped in the following order:
- sshd (stop priority: 25)
- kdump (stop priority: 80)
- iptables (stop priority: 92)
Red Hat Linux comes with a command line utility named chkconfig which is used to manage the startup configuration of init.d services. Refer to our article Linux chkconfig command Usage With Examples to learn about Linux chkconfig command line utility.


{ 0 comments… add one now }