Difference between revisions of "How to Set Linux Programs to Run at Each runlevel"

From HyperSecurity Wiki
Jump to: navigation, search
 
Line 4: Line 4:
  
 
keytable 0:off 1:on  2:on  3:on 4:on  5:on 6:off
 
keytable 0:off 1:on  2:on  3:on 4:on  5:on 6:off
 +
 
atd      0:off 1:off 2:off 3:on 4:on  5:on 6:off
 
atd      0:off 1:off 2:off 3:on 4:on  5:on 6:off
 +
 
syslog  0:off 1:off 2:on  3:on 4:on  5:on 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
 
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
 
kudzu    0:off 1:off 2:off 3:on 4:on  5:on 6:off
 +
 
wlan    0:off 1:off 2:on  3:on 4:on  5:on 6:off
 
wlan    0:off 1:off 2:on  3:on 4:on  5:on 6:off
 +
 
sendmail 0:off 1:off 2:off 3:on 4:off 5:on 6:off
 
sendmail 0:off 1:off 2:off 3:on 4:off 5:on 6:off
 +
 
netfs    0:off 1:off 2:off 3:on 4:on  5:on 6:off
 
netfs    0:off 1:off 2:off 3:on 4:on  5:on 6:off
 +
 
network  0:off 1:off 2:on  3:on 4:on  5:on 6:off
 
network  0:off 1:off 2:on  3:on 4:on  5:on 6:off
 +
 
random  0:off 1:off 2:on  3:on 4:on  5:on 6:off
 
random  0:off 1:off 2:on  3:on 4:on  5:on 6:off
 
...
 
...

Revision as of 06:36, 14 March 2006

As stated earlier, the chkconfig command can be used to adjust which applications start at each runlevel. You can use this command with the --list switch to get a full listing of packages listed in /etc/init.d and the runlevels at which they will be on or off:

[root@bserver tmp]# chkconfig --list

keytable 0:off 1:on 2:on 3:on 4:on 5:on 6:off

atd 0:off 1:off 2:off 3:on 4:on 5:on 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

wlan 0:off 1:off 2:on 3:on 4:on 5:on 6:off

sendmail 0:off 1:off 2:off 3:on 4:off 5:on 6:off

netfs 0:off 1:off 2:off 3:on 4:on 5:on 6:off

network 0:off 1:off 2:on 3:on 4:on 5:on 6:off

random 0:off 1:off 2:on 3:on 4:on 5:on 6:off ...

...

chkconfig Examples

You can use chkconfig to change runlevels for particular packages. Here we see sendmail will start with a regular startup at runlevel 3 or 5. Let's change it so that sendmail doesn't startup at boot.

Use Chkconfig to Get a Listing of sendmail's Current Startup Options

The chkconfig command can be used with grep to determine the run levels in which sendmail will run. Here we see it will run at levels 3 and 5.

[root@server tmp]# chkconfig --list | grep mail

sendmail 0:off 1:off 2:off 3:on 4:off 5:on 6:off

[root@server tmp]#

Switch Off sendmail Starting Up in Levels 3 and 5

The chkconfig command with the --level switch indicates that some action needs to be done at the runlevels entered as its values. The first argument in the command is the package you want to affect and the second defines whether you want it on or off. In this case we want sendmail not to be started when entering runlevels 3 and 5:

[root@server tmp]# chkconfig --level 35 sendmail off
[root@server tmp]#

By not specifying the runlevels with the --level switch, chckconfig will make the changes for runlevels 3 and 5 automatically:

[root@server tmp]# chkconfig sendmail off

Because the intention is to permanently shutdown sendmail permanently, we might also have to stop it from running now.

[root@server tmp]# service sendmail stop

Shutting down sendmail: [ OK ]

Shutting down sm-client: [ OK ]

[root@server tmp]#