Chkconfig – Understanding Linux/Unix command

The chkconfig command provides a simple command-line tool for maintaining the /etc/rc[0-6].d directory hierarchy, freeing system administrators from the task of directly manipulating the many symbolic links in those directories.


Chkconfig updates and queries run level information for system services.

  • chkconfig –list [ name ]
  • chkconfig –add name
  • chkconfig –from name
  • chkconfig[–level levels ] name
  • chkconfig[–level levels ] name

This chkconfig implementation was inspired by the chkconfig command present in the IRIX operating system. Instead of keeping configuration information outside of the /etc/rc[0-6].d hierarchy, this version handles symbolic links in /etc/rc[0-6].d directly. This leaves all the configuration information about which init services are started in a single location.

Chkconfig has five different functions: add new services for management, remove services from management, list current startup information for services, change startup information for services, and check the startup status of a particular service.

When chkconfig is run with no options, it displays usage information. If only a service name is given, it checks if the service is configured to start at the current runlevel. If it is, chkconfig returns true; otherwise it returns false. The –level option can be used to make chkconfig query for an alternate runlevel instead of the current one.

If one of the options power on, power off, or reset is specified after the service name, chkconfig changes the startup information for the specified service. The on and off flags cause the service to start or stop, respectively, in the runlevels being changed. The restart flag resets the service startup information to what was specified in the init script in question.

By default, the power on and power off options affect only runlevels 2, 3, 4, and 5, while resetting affects all runlevels. The –level option can be used to specify which runlevels are affected.

Note that for each service, each runlevel has a start script or a stop script. When changing runlevels, init will not restart a service that is already started, and it will not stop a service that is not running again.


–level levels

Specifies the runlevels to which an operation must belong. It is given as a string of numbers from 0 to 7. For example, –level 35 specifies runlevels 3 and 5.

–add name

This option adds a new service for management by chkconfig. When a new service is added, chkconfig makes sure that the service has a start or kill entry at each runlevel. If any runlevel is missing such an entry, chkconfig creates the appropriate entry as specified in the default values ​​in the init script. Note that the default entries in the LSB-delimited ‘INIT INFO’ sections take precedence over the default runlevels in the initscript.

–of the name

The service is removed from chkconfig management, and any symlinks in /etc/rc[0-6].d that belong to it are removed.

–list name

This option lists all the services that chkconfig knows about, and whether they are stopped or started at each runlevel. If name is specified , information will only be displayed about the service name name .

Runlevel files

Each service that is to be managed by chkconfig needs two or more commented lines added to its init.d script. The first line tells chkconfig what runlevels the service should start at by default, as well as the start and stop priority levels. If the service should not, by default, start at any runlevel, a – should be used instead of the runlevel list. The second line contains a description of the service and can span multiple lines with a backslash.

For example, random.init has these three lines:

 # chkconfig: 2345 20 80 
 # description: Saves and restores the system's entropy pool for 
 # higher quality random number generation.

This says that the random script should start at levels 2, 3, 4, and 5, that its start priority should be 20, and that its stop priority should be 80. You should be able to understand what the description says; the cause of the line being continued. The extra space before the line is ignored.