Redhat:Runlevel control

From Define Wiki
Jump to navigation Jump to search

Runlevel Control

While the run levels are generally defined, the specific services that are started up in each run level can be controlled.

Each run level has a direcotry which defined the services to be started. As an example for run level 3, the directory /etc/rc3.d defines the services.

When the system is started a command is run which will locate the run levels directory. The loop defined in the /etc/rc.d/rc file will start each script in turn. The files are named K<number><service> and S<number><service>. The services are started in order starting with the K files and then the S files.

exec /etc/rc.d/rc $RUNLEVEL

Stop a script booting for a run level

There are two ways to change which services are booted for a run level.

Manual changes

Rename the service file in /etc/rc.d/rc<runlevel> from S* or K* to something else.

Command Line Changes

Use the chkconfig command to check and change the run levels

chkconfig --list postfix
postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off
chkconfig <service> on #turn a service on for run levels 2-5
chkconfig <service> off #turn a service off for run levels 2-5
chkconfig  --level 4 <service> on #turn a service on for run level 4