Monday 9 May 2011

Disabling services that are started via the rc scripts

Disabling services that are started via the rc scripts
When Linux. is started, that are scripts (programs) in certain directories that cause certain programs to be executed. Most of these scripts cause services to be started. Red Hat Linux. has a nice utility to control the enabling or disabling of these scripts that start services. This utility, called chkconfig can be used to easily see what services are starting and then allow you to disable them. To see which scripts chkconfig has under its control, type:

chkconfig --list
You should see output with lines similar to the following (only more of them):

atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
rwhod 0:off 1:off 2:off 3:off 4:off 5:off 6:off
keytable 0:off 1:on 2:on 3:on 4:on 5:on 6:off
nscd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
syslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off
gpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off
kudzu 0:off 1:off 2:off 3:on 4:on 5:on 6:off
kdcrotate 0:off 1:off 2:off 3:off 4:off 5:off 6:off
portmap 0:off 1:off 2:off 3:on 4:off 5:off 6:off


In looking at the above, you see that the output includes the numbers 0-6 followed by a colon and either "on" or "off". Exactly what the numbers mean is beyond the scope of this article. For our purposes, we just want to know that if we want a service to be disabled, we should only see "off" after the numbers for the corresponding lines.

To make things easier to read, try the following command:

chkconfig --list | grep ":on"


This command will only show us the scripts that are executed sometime during startup. In order to disable a startup script, you also use the chkconfig command. For example, in the output above, we see that portmap is started and we do not want it to be, so we need to disable it. This can be done by:

chkconfig --level 0123456 portmap off


This says to disable the "portmap" service for levels 0 through 6 (all levels).

No comments:

Post a Comment

Tweets by @sriramperumalla