Linux chkconfig Command Examples Add,
Remove, View, Change Services
Chkconfig command is used to setup, view, or change services that are configured to start automatically during the system startup.
1. Check Service Startup status from Shell Script
When you execute chkconfig command only with the service name, it returns true if the service is configured for startup. The following code snippet shows how to check whether a service is configured for startup or not from a shell script.
# vi check.sh
chkconfig network && echo "Network service is configured"
chkconfig junk && echo "Junk service is configured"
# ./check.sh
Network service is configured
You can also specifically check whether it is configured for a particular run level or not.
# vi check1.sh
chkconfig network --level 3 && echo "Network service is configured for level 3"
chkconfig network --level 1 && echo "Network service is configured for level 1"
# ./check1.sh
Network service is configured for level 3
2. View Current Status of Startup Services
The �list option displays all the services with the current startup configuration status.
# chkconfig --list
abrtd 0:off 1:off 2:off 3:on 4:off 5:on 6:off
acpid 0:off 1:off 2:off 3:off 4:off 5:off 6:off
atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
To view only the services that are configured to be started during system startup, do the following. Please note that this assumes that your system startup level is 3.
chkconfig --list | grep 3:on
Chkconfig command is used to setup, view, or change services that are configured to start automatically during the system startup.
1. Check Service Startup status from Shell Script
When you execute chkconfig command only with the service name, it returns true if the service is configured for startup. The following code snippet shows how to check whether a service is configured for startup or not from a shell script.
# vi check.sh
chkconfig network && echo "Network service is configured"
chkconfig junk && echo "Junk service is configured"
# ./check.sh
Network service is configured
You can also specifically check whether it is configured for a particular run level or not.
# vi check1.sh
chkconfig network --level 3 && echo "Network service is configured for level 3"
chkconfig network --level 1 && echo "Network service is configured for level 1"
# ./check1.sh
Network service is configured for level 3
2. View Current Status of Startup Services
The �list option displays all the services with the current startup configuration status.
# chkconfig --list
abrtd 0:off 1:off 2:off 3:on 4:off 5:on 6:off
acpid 0:off 1:off 2:off 3:off 4:off 5:off 6:off
atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
To view only the services that are configured to be started during system startup, do the following. Please note that this assumes that your system startup level is 3.
chkconfig --list | grep 3:on