Monday, 17 October 2016

LINUX chkconfig Utility



The Linux chkconfig utility is a command-line tool that allows you to specify in which runlevel to start a selected service, as well as to list all available services along with their current setting. Note that with the exception of listing, you must have superuser privileges to use this command.
Listing the Services
To display a list of system services (services from the /etc/rc.d/init.d/ directory, as well as the services controlled by xinetd), either type chkconfig --list, or use chkconfig with no additional arguments.
You will be presented with an output similar to the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
~]# chkconfig --list
NetworkManager 0:off 1:off 2:on 3:on 4:on 5:on 6:off
abrtd 0:off 1:off 2:off 3:on 4:off 5:on 6:off
acpid 0:off 1:off 2:on 3:on 4:on 5:on 6:off
anamon 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
auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
avahi-daemon 0:off 1:off 2:off 3:on 4:on 5:on 6:off
... several lines omitted ...
wpa_supplicant 0:off 1:off 2:off 3:off 4:off 5:off 6:off
 
xinetd based services:
chargen-dgram: off
chargen-stream: off
cvs: off
daytime-dgram: off
daytime-stream: off
discard-dgram: off
... several lines omitted ...
time-stream: off

Each line consists of the name of the service followed by its status (on or off) for each of the seven numbered runlevels. 

For example, in the listing above, NetworkManager is enabled in runlevel 2, 3, 4, and 5, while abrtdruns in runlevel 3 and 5. 

The xinetd based services are listed at the end, being either on, or off

To display the current settings for a selected service only, use chkconfig --list followed by the name of the service:
1
chkconfig --list service_name
For example, to display the current settings for the sshd service, type:
1
2
~]# chkconfig --list sshd
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

You can also use this command to display the status of a service that is managed by xinetd.
In that case, the output will only contain the information whether the service is enabled or disabled:
1
2
~]# chkconfig --list rsync
rsync off

 

No comments: