This tutorial explains Linux “chkconfig” command, options and its usage with examples.
It updates and queries runlevel information for system services. Chkconfig command is used to setup, view, or change services that are configured to start automatically during the system startup.
chkconfig has five distinct functions: adding new services for management, removing services from management, listing the current startup information for services, changing the startup information for services, and checking the startup state of a particular service.
When chkconfig is run without any options, it displays usage information. If only a service name is given, it checks to see if the service is configured to be started in the current runlevel. If it is, chkconfig returns true; otherwise it returns false.
The –level option may be used to have chkconfig query an alternative runlevel rather than the current one.
If one of on, off, or reset is specified after the service name, chkconfig changes the startup information for the specified service.The reset flag resets the startup information for the service to whatever is specified in the init script in question.
By default, the on and off options affect only runlevels 2, 3, 4, and 5, while reset affects all of the runlevels. The –level option may be used to specify which runlevels are affected.
Following are the available run levels
0 – halt
1 – Single user mode
2 – Multiuser, without NFS
3 – Full multiuser mode
4 – unused
5 – X11
6 – reboot
chkconfig –list [name] chkconfig –add name
chkconfig –del name
chkconfig [–level levels] name
chkconfig [–level levels] name
1. Check Service Startup status
$ chkconfig network && echo "Network service is configured"
When you execute chkconfig command only with the service name, it returns true if the service is configured for startup.
You can also specifically check whether it is configured for a particular run level or not.
$ chkconfig network --level 3 && echo "Network service is configured for level 3" OR $ chkconfig network --level 1 && echo "Network service is configured for level 1"
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 .......
3. Add a new Service to the Startup
Use –add option for that purpose. The ‘chkconfig –add’ command will also turn on level 2, 3, 4 and 5 automatically for that service.
$ chkconfig --add $ chkconfig --list | grep iptables .... 0:off 1:off 2:on 3:on 4:on 5:on 6:off ....
Note : If the service doesn’t exist, you should first install it before adding it to the system startup list.
4. Remove a Service From Startup List
To remove it from the startup list, use the –del option as shown below.
$ chkconfig --del ip6tables
5. Turn-on or Turn-off a Service for a Selected Run Level
The following example will turn off for level 5.
$ chkconfig --level 5 off
The following example will turn off for both level 3 and 5.
$ chkconfig --level 35 off
Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.
- Apply for Programming Internship
- Apply for Linux Internship
- Buy Linux Books
- Buy Information Technology Books
- Practice Programming MCQs