chkconfig Cheat Sheet
Category : Cheat Sheets
Controlling startup services in Linux distributions such as Red Hat Enterprise Linux (RHEL), CentOS and Oracle Enterprise Linux (OEL) can be done using a Gnome GUI or a command line utility. The command line utility is called chkconfig and can list existing, add new or remove services from the operating systems startup list.
As Linux operating systems have multiple states, or runlevels, you need to make sure you add any new services to the correct runlevels. For example, you would not want to start a web service application before starting networking. See my post on runlevels.
What services are available for startup?
Use the –list switch to see your existing services and when they should be running.
An example output is below. This shows all of the machine runlevels and what the state of the service will be.
chkconfig --list Note: This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by native systemd configuration. modules_dep 0:off 1:off 2:on 3:on 4:on 5:on 6:off netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off network 0:off 1:off 2:off 3:on 4:off 5:off 6:off
In this example, there are three services available. netconsole is not available at any runlevels and is therefore never started automatically, network is available only in runlevel 3 and modules_dep is available in runlevel 2 and runlevel 3.
You could also use the example below to detail the runlevels of a single service only.
chkconfig network --list
Add a new service with chkconfig
Adding a new service is easily done with the below command. The below example shows the service network being enabled to start at the next machine boot.
chkconfig network on
Use the –level switch to enable the service at specific runlevels. Use the below example to enable the service at runlevel 3.
chkconfig network on --level 3
Remove a service with chkconfig
Removing an existing service is done with the below command. The below example shows the service network being disabled from automatic start.
chkconfig network off
Use the –level switch to remove the service from specific runlevels. Use the below example to disable the service at runlevel 3.
chkconfig network off --level 3
Start a service
Starting a service is done using the command service followed by the service name and the command to start the service.
service network start
Stop a service
Use the stop keyword with service to stop a service.
service network stop
Check the status of a service
Each service has a status, usually running or not running. Some services, such as network, may have a different output and output more information on the service.
service network status
Let me know in the comments if you think anything is missing.