Product SiteDocumentation Site

7.2.3. Using the chkconfig Utility

The chkconfig utility is a command line application to configure which services are to be started in selected runlevels. It also allows you to list all available services along with their current setting. Note that with the exception of listing, you must have superuser privileges to use this command. To obtain them, log in as root by typing:
~]$ su -
Password:

7.2.3.1. Listing the Services

To display a list of system services (i.e., both the services from the /etc/rc.d/init.d/ directory, and the services controlled by xinetd), either type chkconfig --list, or use chkconfig with no additional arguments. You should be presented with an output similar to this:
Example 7.1. Listing the services
~]# chkconfig --list
NetworkManager  0:off   1:off   2:on    3:on    4:on    5:on    6:off
abrtd           0:off   1:off   2:off   3:on    4:off   5:on    6:off
acpid           0:off   1:off   2:on    3:on    4:on    5:on    6:off
anamon          0:off   1:off   2:off   3:off   4:off   5:off   6:off
atd             0:off   1:off   2:off   3:on    4:on    5:on    6:off
auditd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
avahi-daemon    0:off   1:off   2:off   3:on    4:on    5:on    6:off
... several lines omitted ...
wpa_supplicant  0:off   1:off   2:off   3:off   4:off   5:off   6:off

xinetd based services:
        chargen-dgram:  off
        chargen-stream: off
        cvs:            off
        daytime-dgram:  off
        daytime-stream: off
        discard-dgram:  off
... several lines omitted ...
        time-stream:    off

As you can see, each line consists of the name of the service followed by its status (on or off) for each of the seven numbered runlevels. For example, in the listing above, NetworkManager is enabled for runlevel 2, 3, 4, and 5, while abrtd runs in runlevel 3 and 5. The xinetd based services are listed at the end, being either on, or off.
To display the current settings for selected service only, use chkconfig --list followed by the name of the service:
Example 7.2. Listing a single service
~]# chkconfig --list sshd
sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off

You can also use chkconfig --list <service> to display the status of a service that is managed by xinetd. In that case, the output will simply contain the information whether the service is enabled or disabled:
Example 7.3. Listing a service that is managed by xinetd
~]# chkconfig --list rsync
rsync           off

7.2.3.2. Enabling the Service

To enable the service for runlevels 2, 3, 4, and 5 at the same time, type chkconfig <service> on. For instance:
~]# chkconfig httpd on
To enable the service for certain runlevels only, add the --level option followed by the string of numbers from 0 to 6 representing each runlevel in which you want the service to run. For example, to enable the abrtd for runlevels 3 and 5, type:
~]# chkconfig abrtd on --level 35
The service will be started the next time you enter one of these runlevels. If you need to start the service immediately, use the service command as described in Section 7.3.1.1, “Running the Service”.
To enable the service that is managed by xinetd, use chkconfig <service> on only, as the --level option is not allowed:
~]# chkconfig rsync on
If the xinetd daemon is running, the service is immediately enabled without having to restart the daemon manually.

7.2.3.3. Disabling the Service

To disable the service for runlevels 2, 3, 4, and 5 at the same time, type chkconfig <service> off. For instance:
~]# chkconfig httpd off
To disable the service for certain runlevels only, add the --level option followed by the string of numbers from 0 to 6 representing each runlevel in which you do not want the service to run. For example, to disable the abrtd for runlevels 2 and 4, type:
~]# chkconfig abrtd off --level 24
The service will be stopped the next time you enter one of these runlevels. If you need to stop the service immediately, use the service command as described in Section 7.3.1.2, “Stopping the Service”.
To disable the service that is managed by xinetd, use chkconfig <service> off only, as the --level option is not allowed:
~]# chkconfig rsync off
If the xinetd daemon is running, the service is immediately disabled without having to restart the daemon manually.