Linux chkconfig Command with Examples

July 20, 2022

Introduction

Modern Linux distributions come with the systemd initialization system that allows users to manage services with the systemctl command.

However, some older systems still use System V or Upstart. In that case, use the chkconfig command to list, start, and stop services, as well as enable or disable services from startup.

This guide will show you how to use the chkconfig command to control system services in Linux.

Linux chkconfig Command with Examples

Prerequisites

  • A system running System V or Upstart.
  • Access to the terminal/command line.
  • Access to an account with root or sudo privileges.

The chkconfig Command Syntax

The chkconfig command syntax looks like this:

chkconfig [options] [service] [subcommand]

The command works on its own but can also be used with:

  • The --list, --level, --add, --del, and --override options specified before the service name. The options print the details or manage the service in question.
  • The onoffreset, or resetpriorities subcommands added after the service name. The subcommands change the startup info for the specified service.

The chkconfig Command Options

Running the chkconfig command without any options outputs the current configuration of all services:

The chkconfig Command Terminal Output

However, executing the command with different options and subcommands enables users to manage services instead of only listing them. The table below shows the options and subcommands used with the chkconfig command:

OptionDescription
--listDisplays all services and their current startup status in each runlevel.
--list | sortSorts services alphabetically and displays them with their current startup status in each runlevel.
--list | grep onShows only running services and their current startup status in each runlevel.
--list | grep offShows only services disabled in one or more runlevels and their current startup status in each runlevel.
--list | grep --level <levels>:onLevel-specific: Prints services running in a particular runlevel.
--list | grep --level <levels>:offLevel-specific: Prints services that are disabled in a certain runlevel.
--list [service]Outputs the status of a particular service in each runlevel.
[service] onEnables a service to start on system boot.
[service] offDisables a service from starting on system boot.
--level <levels> [service] onTurns on a particular service in a single or multiple runlevels.
--level <levels> [service] offTurns off a particular service in single or multiple runlevels.
--add [service]Adds a service to startup in all runlevels.
--del [service]Removes a service from the startup in all runlevels.
[service] resetResets the on/off statuses of all services.
[service] resetprioritiesResets the start/stop priorities of all services.
--override [service]Reconfigures a service to the override settings instead of the default configuration.

The chkconfig Command Examples

The chkconfig command is the ultimate service managing tool for older Linux systems. The sections below outline common chkconfig examples.

List All Services

To list all services, execute the command without options or run:

chkconfig --list
The chkconfig --List Command Terminal Output

Using --list with the chkconfig command displays the status of all available services in all runlevels. In case you want to sort services in alphabetical order, use the sort option:

chkconfig --list |sort
The chkconfig --list sort Command Terminal Output

The chkconfig --list command also works in RHEL 7. However, the output only displays Sys V services and not native system services:

The chkconfig --list Command Terminal Output in RHEL 7

List All Enabled Services

To find all enabled services (in one or multiple runlevels), execute combine chkconfig --list with the grep command:

chkconfig --list | grep on
The chkconfig --list grep on Command Terminal Output

To find all disabled services (in one or multiple runlevels), run:

chkconfig --list | grep off
The chkconfig --list grep off Command Terminal Output

Furthermore, to narrow down the scope to the services on/off a particular runlevel, use:

chkconfig --list | grep --level <levels>:on
chkconfig --list | grep --level <levels>:off

For example, list all the services running in runlevel 5 with:

chkconfig --list | grep 5:on
The chkconfig --list grep 5 on Command Terminal Output

On the other hand, to display all the services that are not running in runlevel 5, execute:

chkconfig --list | grep 5 :off
The chkconfig --list grep 5 off Command Terminal Output

List a Particular Service

To show the startup configuration of a particular service in all runlevels, run chkconfig --list and specify the service.

chkconfig --list [service]

For example, check the status of the ntpd service in all runlevels with:

chkconfig --list ntpd
The chkconfig --list ntpd Command Terminal Output

The output shows that the ntpd service is disabled on boot in any runlevel.

Enable a Service

Enable a service to start on boot with the chkconfig [service] on command. Next, confirm that the service is on using <strong>--list</strong>.

chkconfig [service] on
chkconfig --list [service]
The chkconfig ntpd on Command Terminal Output

The on option affects runlevels 2, 3, 4, and 5 and starts the ntpd service on boot on these runlevels. To enable a service on one or multiple runlevels only, run:

chkconfig  --level <levels> [service] on

For example, start the ntpd service on the third runlevel and verify the service’s configuration with:

chkconfig  --level 3 ntpd on
chkconfig --list ntpd
The chkconfig --level 3 ntpd on Command Terminal Output

Similarly, to turn on the ntpd service in multiple runlevels in one go use:

chkconfig  --level 235 ntpd on
chkconfig --list ntpd
The chkconfig --level 235 ntpd on Command Terminal Output

Disable a Service

Disable a service from starting at system boot with the chkconfig [service] off command:

chkconfig [service] off
chkconfig --list [service]
The chkconfig ntpd off Command Terminal Output

Even though the off variable also affects runlevels 2 to 5, users can specify in which runlevels to disable a service.

For instance, disable the ntpd service only in runlevel 3 and verify the results with:

chkconfig  --level 3 ntpd off
chkconfig --list ntpd
The chkconfig --level 3 ntpd off Command Terminal Output

Add a Service     

Add a service to startup in all runlevels with the following command:

chkconfig --add [service]

For example, use the --add option to add ntpd to startup in all runlevels. Next, use --list to verify the service has been added:

chkconfig --add ntpd
chkconfig --list ntpd
The chkconfig --add ntpd Command Terminal Output

The chkconfig command adds and configures the service as specified by the default values in the init script. For example, the ntpd service is disabled in every runlevel by default.

Note: The command adds a service only if its available and installed. If the service has not been installed, install its package first.

Remove a Service

Remove a service from startup in all runlevels with the --del option:

chkconfig --del [service]
The chkconfig --del ntpd Command Terminal Output

The --del option removes the service from startup, but the service remains in the system. Therefore, to add the service back to startup, use the --add option again.

Reset Service Configuration

To reset the on/off status of a service in all runlevels as specified in the init script, execute:

chkconfig [service] reset
The chkconfig ntpd reset Command Terminal Output

The output shows that ntpd returns to the default off status in all runlevels.

Conclusion

After reading this tutorial, you know how to use the chkconfig command to manage services in older versions of Linux.

Next, learn how to use the systemctl command to start, stop, and restart Linux services on newer Linux distributions.

Was this article helpful?
YesNo
Sara Zivanov
Sara Zivanov is a technical writer at phoenixNAP who is passionate about making high-tech concepts accessible to everyone. Her experience as a content writer and her background in Engineering and Project Management allows her to streamline complex processes and make them user-friendly through her content.
Next you should read
How To Use grep Command In Linux/UNIX
February 29, 2024

This guide details the most useful grep commands for the Linux/Unix system. After going through all the commands and examples, you will learn how to use the grep command to search files for text from the terminal...
Read more
How to List Installed Packages on CentOS with Yum or RPM
April 29, 2019

Managing a CentOS operating system often means knowing the software packages that are installed. This guide provides methods to list installed software packages...
Read more
How to Check CentOS Version?
April 8, 2019

There are many reasons to know the CentOS version you are running. Outdated software can cause serious security risks and vulnerabilities. In this guide, discover 4 different ways to check the CentOS version...
Read more
CentOS 8 Released: New Features, Changes, & How to Download
October 2, 2019

CentOS 8 was finally released on September 24th, 2019. This is a Linux distribution derived from Red Hat Enterprise Linux...
Read more