chkconfig command in Linux with Examples
'chkconfig' command is used to list all available services and view or update their run level settings. In simple words it is used to list current startup information of services or any particular service, update runlevel settings of service, and adding or removing service from management.
Here we’ll explore the syntax, options, and practical examples of using the 'chkconfig' command to help you gain full control over your system’s services.
Prerequisite: Run Levels in Linux
Syntax
chkconfig --list [name]
chkconfig --add name
chkconfig --del name
chkconfig --override name
chkconfig [--level levels] name
chkconfig [--level levels] name
Common Options used with the 'chkconfig' command
Here are some of the most common options available with the 'chkconfig' command:
Option | Description |
---|---|
--list | Lists the current status of all services or a specific service. |
--add name | Adds a new service to the startup sequence, allowing it to be managed by chkconfig . |
--del name | Removes a service from the startup sequence. |
--level levels | Specifies the run levels to enable or disable a service. |
--override name | Overrides the default settings for a service without affecting its configuration file |
Examples of Using the 'chkconfig' Command
Here are some practical examples that demonstrate how to use the chkconfig command in various scenarios.
1. List current status of all system services
To see a complete list of all services along with their current run level configurations, use the following command:
chkconfig --list

This will output a table showing which services are enabled or disabled at each run level.
2. View current status of a particular services
If you want to check the status of a particular service, such as rhnsd, use:
chkconfig --list rhnsd

This will display the run levels at which the rhnsd service is enabled or disabled.
3. Disabling a Service
By default 2 3 4 5 run levels are affected by this command to disable certain run levels only, add --level attribute followed by run level.
chkconfig rhnsd off

4. Enabling a Service
By default 2 3 4 5 run levels are affected by this command to enable certain run levels only, add --level attribute followed by run level.
chkconfig rhnsd on

5. Delete a Service
To completely remove a service from the startup sequence and prevent it from being managed by chkconfig, use:
chkconfig del rhnsd

6. Add a Service
If a service is not currently managed by chkconfig, you can add it to the startup sequence by running:
chkconfig add rhnsd

This ensures that the service is now manageable through the chkconfig utility and can be enabled or disabled as needed.
Conclusion
The chkconfig command is a powerful tool for managing system services and their run levels in Linux. By mastering this command, system administrators can control the startup behavior of services, optimize system performance, and enhance overall security.