Tag Archives: How to enable service using chkconfig

6 ways to manage service startups using chkconfig in Linux

Learn chkconfig command to list, turn on, or turn off system services during different run levels. Also, see how to control xinetd managed system service.

The chkconfig utility in Linux is a command-line tool to manage system services startups in run levels starting from 0 to 6. Run levels are different system stages in which the system can run with different numbers and combinations of services available for its users. There are mainly 7 run levels defined in the kernel world whereas 0,1 and 6 are not relative in this post. 0,6 run levels are boot/shut related whereas 1 is the single-user mode and we are seeing service management here which is normally comes in a picture for multi-user mode. So only 2,3,4,5 are the run levels that are covered by chkconfig utility when you are altering any services.

chkconfig controls which system service starts in which run level. It can even completely shuts off service so that it won’t run at any run level too. There are xinetd controlled system services that can be turned on or off irrespective of run level. These can be managed through chkconfig too.

Chkconfig is capable of below tasks:

  1. Overview of list of services and their run-level wise availability
  2. Details of individual system service
  3. Enable service at certain/all run levels
  4. Disable service
  5. Enable xinetd managed service
  6. Disable xinetd managed service

If you are on the Ubuntu server then probably chkconfig won’t work on Ubuntu. You can alternatively use update-rc.d command there.

We will see each of the above options in detail with related options and examples.

1. Overview of services and their run-level availability :

For this task, chkconfig displays a list of system services. Against every service, it displays all run levels 0 to 6 and on/off parameter. On means, service is enabled at that run level, and off means service is disabled at that run level. To view this you can run chkconfig command without any argument or with --list option.

# chkconfig --list
NetworkManager  0:off   1:off   2:off   3:off   4:off   5:off   6:off
abrt-ccpp       0:off   1:off   2:off   3:on    4:off   5:on    6:off
abrt-oops       0:off   1:off   2:off   3:on    4:off   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
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:off   6:off
autofs          0:off   1:off   2:off   3:on    4:on    5:on    6:off

-----output clipped-----
xinetd based services:
        chargen-dgram:  off
        chargen-stream: off
        time-stream:    off
----- output clipped -----

In the above output for example system service autofs is enabled for run level 3,4,5 and disabled for 0,1,2,6. It also shows xinetd based service status at the bottom. These services only have on or off status (no run level based status)

2. Details of individual service

In this task the same output as above can be obtained only for a particular service. It is as good as grepping out that service line from the above output. This task can be accomplished by using the service name as an argument to --list option.

# chkconfig --list nfs
nfs             0:off   1:off   2:off   3:off   4:off   5:off   6:off

# chkconfig --list rsync
rsync           off

3. Enable service at certain/all run levels :

Let’s see how to enable service for a particular/all run level. For this task, you need to specify levels (--level) on which services need to enable, followed by service name and lastly on a state.

# chkconfig --level 34 autofs on

In above example we are enabling autofs service in run level 3 and 4.

To enable it in all run levels i.e. 2,3,4,5 you can skip --level option.

# chkconfig autofs on

The above example enables autofs system service at all run levels. You can verify if the service state is set properly as specified in the command, by viewing chkconfig --list output.

4. Disable service

To disable service at certain/all run levels, sane above command can be used only ‘off’ state needs to be specified at the end instead of ‘on’ state.

# chkconfig --level 34 autofs off <<turns off at run level 3 & 4

# chkconfig autofs off <<turns off on all run levels

Make a note that this change is not immediate. Enabling or disabling services will change settings but takes effect only when the system will enter a specific run level after the execution of the command.

5. Enable xinetd managed service:

Since xinetd managed services cant be tagged to run-levels, you can not specify --level option with commands associated with them. To enable xinetd managed service, you need to mention the service name followed by ‘on’ state.

# chkconfig rsync on

Make a note that, change in xinetd managed services will be instant after the execution of the command.

6. Disable xinetd managed service:

To disable xinetd managed services opt ‘off’ state in above command.

# chkconfig rsync off




Observe state change in chkconfig --list output.