LinuxCommandLibrary

chkconfig

Manage system services at boot time

TLDR

List services with runlevel

$ chkconfig --list
copy

Show a service's runlevel
$ chkconfig --list [ntpd]
copy

Enable service at boot
$ chkconfig [sshd] on
copy

Enable service at boot for runlevels 2, 3, 4, and 5
$ chkconfig --level [2345] [sshd] on
copy

Disable service at boot
$ chkconfig [ntpd] off
copy

Disable service at boot for runlevel 3
$ chkconfig --level [3] [ntpd] off
copy

SYNOPSIS

chkconfig [--add name] [--del name] [--list [name]] [name runlevel on|off]

PARAMETERS

--add name
    Adds a new service for management by chkconfig. A corresponding init script must exist in /etc/init.d/.

--del name
    Removes a service from chkconfig's management. It removes the symbolic links in /etc/rc[0-6].d.

--list [name]
    Lists the current startup information for all services, or for a specific service if name is provided.

name runlevel on|off
    Sets the startup behavior of a service (name) for a specific runlevel. runlevel is a number between 0 and 6. 'on' enables the service at that runlevel, 'off' disables it.

DESCRIPTION

chkconfig provides a simple command-line tool for maintaining the /etc/rc.d directory hierarchy. It simplifies the process of managing System V init scripts, which control the starting and stopping of services at different runlevels.
Specifically, chkconfig updates and queries runlevel information for system services. It manipulates the symbolic links in the /etc/rc[0-6].d directories that are used by the init process to determine which services should be started or stopped when the system enters a particular runlevel.
The command works by adding or removing symbolic links within these directories, based on the desired runlevel settings. chkconfig is not used to directly start or stop services; it only manages the configuration of their start/stop behavior across reboots and runlevel changes.
It's important to note that chkconfig is primarily used on systems that utilize System V init. Modern distributions often employ systemd, which uses a different system management approach (systemctl).

CAVEATS

Chkconfig is primarily for System V init systems. It is not used on systemd-based distributions. Using chkconfig on a systemd system may lead to unexpected behavior. The init script needs to have the correct LSB headers for chkconfig to work correctly.

RUNLEVELS

Runlevels define the state of the system. Common runlevels are:
0: Halt
1: Single-user mode
2-5: Multi-user mode
6: Reboot
The startup scripts in /etc/rc[runlevel].d/ determine what services are started or stopped in each runlevel.

INIT SCRIPTS

Init scripts are shell scripts located in /etc/init.d/ that are responsible for starting, stopping, restarting, and querying the status of services. They typically accept arguments like 'start', 'stop', 'restart', and 'status'.

HISTORY

Chkconfig was developed to simplify the management of init scripts in System V init systems. It provided a more user-friendly interface than directly manipulating symbolic links in the /etc/rc.d directories. It became a standard tool on many Linux distributions that used System V init, providing a consistent way to configure service startup behavior. With the adoption of systemd, the use of chkconfig has declined on newer distributions.

SEE ALSO

Copied to clipboard