Managing Linux Services at Startup With Chkconfig Command

Linux chkconfig is a simple command line utility for manage and maintain /etc/rc[0-6].d directory hierarchy. This command is normally used to setup, view or change different services which are configured at startup. Through this command we can control what services start at the time of server startup and in which order. Chkconfig command is having five distinct functions: adding a new service, removing of services, listing the current service startup information, changing the startup information of any service and checking the startup state of a particular service. When we run chkconfig without giving any options, it will display usage information. If we provide only service name then it will check if that service is configured to be started in current run level.

If we specify on or off option with the service name, chkconfig command changes the startup information for that particular service. This on and off flag cause any services to be started or stopped. By default, on and off options affect in run levels 2, 3, 4 and 5. The –level option can be used to specify which run level should be affected. Note that every service in Linux has either a start script or stop script. Below are some practical examples which explain the usage of chkconfig command.

1. Viewing the Current Status of any Service

The –list option is used to display all the services with their current startup configuration.

# chkconfig –list
abrtd 0:off 1:off 2:off 3:on 4:off 5:on 6:off
acpid 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

To view only those services which are configured during system startup, execute the following command. For instance, let us assume that current startup level is 3.

# chkconfig –list | grep 3:on

To view startup configuration of any particular service, use the following command.

# chkconfig –list | grep

2. Adding a new Service at the startup

Here, we can use –add option for a specific service to the list of services which needs to be started at system reboot. Below example shows how to add iptables service to be started during system boot. This command will turn on level 2,3,4 and 5 automatically as below.

# chkconfig –add iptables
# chkconfig –list | grep iptables
iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Note that the above command will only add the service which is present in the system. If the service is not present then you should first install the same and then you can add to the startup list of the system.

3. Remove any service from the startup list

Below mentioned example shows how to remove ip6tables service from the startup list.

# chkconfig –del ip6tables

4.Turn-On or Turn-Off any service for a particular Run Level

Below example will turn off the nfsserver service in run level 5

# chkconfig –level 5 nfsserver off

Even, we can also combine multiple run level in the above example.

# chkconfig –level 35 nfsserver off

Whenever we add or remove any service with chkconfig command, it performs the following in the /etc/rc.d sub directories.
When chkconfig –add is executed, it creates a symbolic link file so that services can be started and stopped under its corresponding rc directory. When chkconfig –del is executed, it removes the same symbolic link from the directory.

About Bobbin Zachariah

Founder of LinOxide, passionate lover of Linux and technology writer. Started his career in Linux / Opensource from 2000. Love traveling, blogging and listening music. Reach Bobbin Zachariah about me page and google plus page.

Author Archive Page

Have anything to say?

Your email address will not be published. Required fields are marked *

All comments are subject to moderation.