chkconfig

system managementLinux (RHEL/CentOS/Fedora)
The chkconfig command is one of the most frequently used commands in Linux/Unix-like operating systems. chkconfig Tool for managing services in SysV init systems

Quick Reference

Command Name:

chkconfig

Category:

system management

Platform:

Linux (RHEL/CentOS/Fedora)

Basic Usage:

chkconfig [options] [arguments]

Common Use Cases

  • 1

    Service management

    Configure system services to start at boot time

  • 2

    System administration

    Manage which services are enabled or disabled

  • 3

    Boot optimization

    Optimize system boot time by controlling services

  • 4

    Service security

    Disable unnecessary services for security hardening

Syntax

chkconfig [--list] [--type type] [name]
chkconfig --add name
chkconfig --del name
chkconfig [--level levels] name <on|off|reset|resetpriorities>

Options

Option Description
--level levels Specify runlevels to operate on (0-6)
--add name Add a new service for management by chkconfig
--del name Remove a service from chkconfig management
--list [name] List services (or specific service) and their current configuration
--type type List only specified type of services (sysv, xinetd)
--override name Override system-wide enablement state for a specific service
--help Display help message and exit

Examples

How to Use These Examples

The examples below show common ways to use the chkconfig command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

Basic Examples:

List all services and their current settings
chkconfig --list
Check if a specific service is configured to start at boot
chkconfig --list httpd
Enable a service to start at boot in runlevels 3, 4, and 5
sudo chkconfig --level 345 httpd on
Disable a service from starting at boot
sudo chkconfig httpd off
Add a new service to be managed by chkconfig
sudo chkconfig --add custom-service

Advanced Examples:

List only xinetd services
chkconfig --list --type xinetd
Enable a service for all valid runlevels
sudo chkconfig sshd on
Configure multiple services in one command
sudo chkconfig --level 345 httpd on postgresql on vsftpd off
Reset a service to default settings
sudo chkconfig --level 345 httpd reset
Reset priorities for a service to defaults
sudo chkconfig httpd resetpriorities

Try It Yourself

Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

Understanding Syntax

Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

Notes

The chkconfig command is used to manage system services in Linux distributions that use the System V (SysV) initialization system. It updates and queries runlevel information for system services.

Important considerations:

  • chkconfig has been replaced by systemctl in systems using systemd (most modern Linux distributions).
  • The command primarily works with scripts in /etc/init.d/ and configuration in /etc/rc.d/.
  • Root privileges are required to make changes to service configurations.
  • The runlevels in Linux typically include:
    • 0: System halt/shutdown
    • 1: Single user mode
    • 2: Multi-user mode without networking
    • 3: Multi-user mode with networking (no GUI)
    • 4: Not used/user-defined
    • 5: Multi-user mode with networking and GUI
    • 6: System reboot
  • For a service to be managed by chkconfig, it needs special comments (chkconfig tags) in its init script.

When creating a new service to be managed by chkconfig, the init script should include a chkconfig comment line such as:

# chkconfig: 345 20 80

Where "345" are the runlevels, "20" is the start priority, and "80" is the stop priority.

For modern systemd-based systems, equivalent functionality is provided by:

systemctl enable/disable service_name
systemctl list-unit-files --type=service

Common Use Cases

Service management

Configure system services to start at boot time

System administration

Manage which services are enabled or disabled

Boot optimization

Optimize system boot time by controlling services

Service security

Disable unnecessary services for security hardening

System maintenance

Manage service configurations for system maintenance

Related Commands

These commands are frequently used alongside chkconfig or serve similar purposes:

Use Cases

1

Service management

Configure system services to start at boot time

2

System administration

Manage which services are enabled or disabled

3

Boot optimization

Optimize system boot time by controlling services

4

Service security

Disable unnecessary services for security hardening

5

System maintenance

Manage service configurations for system maintenance

Learn By Doing

The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the chkconfig command works in different scenarios.

$ chkconfig
View All Commands