chkconfig

2024-05-10

Understanding System Services

Before diving into chkconfig, it’s important to understand what system services are. These are background processes that start automatically when the system boots and provide essential functionalities like networking, logging, and more. chkconfig allows you to control whether these services start at boot time and their runlevels.

Runlevels: The Core Concept

Runlevels define the system’s operational state. Traditional SysVinit systems have many runlevels (typically 0-6), each representing a different operational mode (e.g., 0 for halt, 1 for single-user mode, 3 for multi-user mode with networking, 5 for graphical multi-user mode, 6 for reboot). chkconfig allows you to specify which runlevels a service should be active in.

Key chkconfig Commands

Here’s a breakdown of the most commonly used chkconfig commands with illustrative examples:

1. Listing Services:

To view the current status of all services and their enabled/disabled state across various runlevels:

sudo chkconfig --list

This command will display a table showing each service and whether it’s set to start (on) or not (off) in each runlevel.

2. Enabling a Service:

To enable a service (e.g., httpd – Apache web server) to start at boot time for runlevels 3, 4, and 5:

sudo chkconfig httpd on

3. Disabling a Service:

To prevent a service (e.g., nfs – Network File System) from starting at boot time for all runlevels:

sudo chkconfig nfs off

4. Setting Service Status for Specific Runlevels:

For more granular control, you can specify the runlevel(s) where the service should be enabled or disabled. For example, to enable sshd (SSH daemon) only in runlevel 3:

sudo chkconfig sshd on 3

5. Checking a Service’s Status in a Specific Runlevel:

To check the status of crond (cron daemon) in runlevel 5:

sudo chkconfig --list crond | grep 5

6. Deleting a Service from chkconfig:

While not directly deleting the service itself, you can remove its entry from chkconfig’s management if it’s no longer needed:

sudo chkconfig --del <service_name> 

(Replace <service_name> with the actual service name).

Important Considerations

This detailed exploration of chkconfig provides a solid foundation for managing system services on older Linux systems. Remember to tailor these examples to your specific services and needs. Always exercise caution when modifying system services.