Sunday, August 28, 2016

chkconfig - Runlevels

In addition to insserv, you can also use the chkconfig command to manage a daemon’s runlevels. If you want to view a service’s current runlevel configuration, enter chkconfig –l daemon_name at the shell prompt. You can also enter chkconfig –l to see the status of all daemons installed on your system. In the example that follows, the chkconfig command is used to view the runlevel configuration of the ntp daemon: 
ws1:/etc/init.d # chkconfig -l ntp
ntp                       0:off  1:off  2:off  3:off  4:off  5:off  6:off
As you can see here, the ntp service has not been configured to start at any runlevel. If you want to configure a daemon to start at its default runlevels, you can enter chkconfig daemon_name on. You can also specify exactly what levels you want a daemon to start on using the chkconfig command. For example, suppose we wanted the ntp daemon to run in runlevels 3 and 5. We could make this happen by entering chkconfig –s ntp 35. This specifies that the ntp service (specified by the –s option) be enabled at runlevels 3 and 5. This is shown here: 
ws1:/etc/init.d # chkconfig -s ntp 35
ws1:/etc/init.d # chkconfig -l ntp
ntp                       0:off  1:off  2:off  3:on   4:off  5:on   6:off
To disable a service, enter chkconfig service_name off. For example, to disable the ntp service enabled previously, you would enter chkconfig ntp off
ws1:/etc/init.d # chkconfig ntp off
ws1:/etc/init.d # chkconfig -l ntp
ntp                       0:off  1:off  2:off  3:off  4:off  5:off  6:off
You can also use chkconfig to view the runlevel configuration of all the services installed on your system by simply entering chkconfig –l, as shown here: 

ws1:/etc/init.d # chkconfig -l

No comments:

Post a Comment