Linux - chkconfig


What is chkconfig?

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

This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by native systemd configuration.

What are the five distinct function of chkconfig?

chkconfig has five distinct functions:

  • adding new services for management
  • removing services from management
  • listing the current startup information for services
  • changing the startup information for services
  • checking the startup state of a particular service.

How can we check to see if a particular service is configured to be started in the current runlevel?

chkconfig nagios
chkconfig ddclient && echo "ddclient service is configured"

When chkconfig is run with only a service name, it checks to see if the service is configured to be started in the current runlevel. If it is, chkconfig returns true; otherwise it returns false.

How can we check to see if a particular service is configured to be started in a particular runlevel?

chkconfig nagios --level 5 && echo "Nagios is configured"

The —level option may be used to have chkconfig query an alternative runlevel rather than the current one.

How can we display a listing of all services and their current configuration?

chkconfig --list

When chkconfig is run with the —list argument, or no arguments at all, a listing is displayed of all services and their current configuration.

How can we tell chkconfig to start to manage a service?

chkconfig --add nagios
chkconfig nagios on

The ‘chkconfig –add’ command will also turn on level 2, 3, 4 and 5 automatically. Apparently, 'chkconfig —add' did not automatically turn on level 2, 3, 4 and 5, and we have to run 'chkconfig nagios on'

Note: “chkconfig –add” only adds an existing service to the list of startup. If the service doesn’t exist, you should first install it before adding it to the system startup list. While this is pretty obvious, it is worth to mention it, as a newbie might make this mistake.

chkconfig httpd on
systemctl is-enabled httpd.service
systemctl enable httpd.service

How can we remove a service from chkconfig?

chkconfig --del nagios

How can we turn-on or turn-off a service for a specific run level?

Sometimes you might not want to delete the whole service. Instead, you might just want to turn the flag on or off for a particular run level (for a particular service).

chkconfig --level 5 nagios off

You can also combine multiple levels. The following example will turn off nfsserver for both level 3 and 5:

chkconfig --level 35 nagios off

How can we change the startup information for a specific service?

chkconfig nagios on
chkconfig nagios on --level 5
chkconfig nagios off 
chkconfig nagios off --level 5

The —level option may be used to specify which run‐levels are affected.

If one of on, off, reset, or resetpriorities is specified after the service name, chkconfig changes the startup information for the specified service. The on and off flags cause the service to be started or stopped, respectively, in the runlevels being changed. The reset flag resets the on/off state for all runlevels for the service to whatever is specified in the init script in question, while the resetpriorities flag resets the start/stop priorities for the service to whatever is specified in the init script.

By default, the on and off options affect only runlevels 2, 3, 4, and 5, while reset and resetpriorities affects all of the runlevels.

Will chkconfig re-start an already-started service?

Note that for every service, each runlevel has either a start script or a stop script. When switching runlevels, init will not re-start an already-started service, and will not re-stop a service that is not running.

Can chkconfig manage xinetd scripts?

chkconfig also can manage xinetd scripts via the means of xinetd.d configuration files. Note that only the on, off, and —list commands are supported for xinetd.d services.

What is the purpose of the —type argument?

chkconfig supports a —type argument to limit actions to only a specific type of services, in the case where services of either type may share a name. Possible values for type are sysv and xinetd.

On this page, nagios is the name of the particular service.

What is the purpose of the —level argument?

—level levels: Specifies the run levels an operation should pertain to. It is given as a string of numbers from 0 to 6. For example, —level 35 specifies runlevels 3 and 5.

What is the purpose of the —no-redirect argument?

—no-redirect: When chkconfig is run on a system that uses systemd as its init system, chkconfig will forward commands to systemd if a systemd service file exists for it. This switch turns off the redirection to systemd and only operates on the symlinks in /etc/rc[0-6].d. This option is only valid when on, off, or no command (to check enablement) is passed to a service.

What is the purpose of the —add argument?

—add name: This option adds a new service for management by chkconfig. When a new service is added, chkconfig ensures that the service has either a start or a kill entry in every runlevel. If any runlevel is missing such an entry, chkconfig creates the appropriate entry as specified by the default values in the init script. Note that default entries in LSB-delimited 'INIT INFO' sections take precedence over the default runlevels in the initscript; if any Required-Start or Required-Stop entries are present, the start and stop priorities of the script will be adjusted to account for these dependencies.

What is the purpose of the —del argument?

—del name: The service is removed from chkconfig management, and any symbolic links in /etc/rc[0-6].d which pertain to it are removed. Note that future package installs for this service may run chkconfig —add, which will re-add such links. To disable a service, run chkconfig name off.

What is the purpose of the —override argument?

—override name: If service name is configured exactly as it would be if the —add option had been specified with no override file in /etc/chkconfig.d/name, and if /etc/chkconfig.d/name now exists and is specified differently from the base initscript, change the configuration for service name to follow the overrides instead of the base configuration.

What is the purpose of the —list argument?

—list name: This option lists all of the services which chkconfig knows about, and whether they are stopped or started in each runlevel. If name is specified, information in only display about service name.


Each service which should be manageable by chkconfig needs two or more commented lines added to its init.d script. The first line tells chkconfig what runlevels the service should be started in by default, as well as the start and stop priority levels. If the service should not, by default, be started in any runlevels, a - should be used in place of the runlevels list.

The second line contains a description for the service, and may be extended across multiple lines with backslash continuation. For example, random.init has these three lines:

# chkconfig: 2345 20 80
# description: Saves and restores system entropy pool for \
#              higher quality random number generation.
This says that the random script should be started in 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 figure out what the description says; the \ causes the 
line to be continued.  The extra space in front of the line is ignored.

chkconfig also supports LSB-style init stanzas, and will apply them in preference to "chkconfig:" lines where available. A LSB stanza looks like:

# Provides: foo
# Required-Start: bar
# Defalt-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Foo init script

In this case, the start priority of "foo" would be changed such that it is higher than the "bar" start priority, if "bar" is enabled. Care must be taken when adding dependencies, as they can cause vast shifts in the start and stop priorities of many scripts.


File in /etc/chkconfig.d/servicename are parsed using the same comments that chkconfig notices in init service scripts, and override values in the init service scripts themselves.

SEE ALSO: init(8), ntsysv(8), system-config-services(8), systemd

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License