Saturday, December 31, 2011

Something about 'chkconfig'


chkconfig provides a simple command-line tool for maintaining the /etc/rc.d directory hierarchy by relieving system administrators of the task of directly manipulating the numerous symbolic links in those directories. Normally chkconfig will be found on Redhat Linux, Fedora and CentOS.
Chkconfig has five distinct functions which is 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.

Below are those examples explains how to use the chkconfig command:
1. View Current Status of Startup Services
The –list option displays all the services with the current startup configuration status.
# chkconfig --list (this will list down all services)
# chkconfig --list | grep network (this will list a service, in above example which is network service only)
2. Add a new Service to the Startup
Use –add option to add a specific service to the list of services that will be started during system reboot.

The following example shows how to add a new service.
# chkconfig --add iptables
# chkconfig --list | grep iptables (to view the new added service)
iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off (output)
3. Remove a Service From Startup List
The following example shows that ip6tables services is configured for startup.
To remove it from the startup list, use the –del option as shown below.
# chkconfig --del ip6tables
# chkconfig --list | grep ip6tables (to check removed service)
4. Turn-on or Turn-off a Service
The following example will turn off ip6tables service
# chkconfig ip6tables off
# chkconfig –level 35 ip6tables off (turn off ip6tables for both level 3 and 5)
       
        chkconfig -t|--terse [names]
       chkconfig -s|--set [name state]
       chkconfig -e|--edit [names]
       chkconfig -c|--check name [state]
       chkconfig -l|--list [--deps] [names]
       chkconfig -A|--allservices
       chkconfig -a|--add [names]
       chkconfig -d|--del [names]