Linux - (Init|Run) Level

> Operating System - Kernel (Windows, Unix, Linux) > Linux / Unix > Linux - Boot (Init service system) > Linux - init process (Sysv ?)

1 - About

The scripts running during boot and shut-down depends of a run level.

The scripts are found in the directory /etc/rc.d/rc#.d/ where the symbol # represents the run level.

The run level “3” will run in the directory /etc/rc.d/rc3.d/ all the scripts which start with the letter:

  • S during system boot.
  • K during shutdown

This system provides an orderly way to bring the system to different states for production and maintenance modes.

Advertising

3 - Run Level

Runlevel Scripts Directory (Red Hat/Fedora Core) State
0 /etc/rc.d/rc0.d/ shutdown/halt system
1 /etc/rc.d/rc1.d/ Single user mode
2 /etc/rc.d/rc2.d/ Multiuser with no network services exported
3 /etc/rc.d/rc3.d/ runlevel “3” (often called console mode) is often used by servers which do not need a graphical user interface. Default text/console only start. Full multiuser
4 /etc/rc.d/rc4.d/ Reserved for local use. Also X-windows (Slackware/BSD)
5 /etc/rc.d/rc5.d/ Runlevel “5” will boot the system into GUI mode using XDM and X-Windows. XDM X-windows GUI mode (Redhat/System V)
6 /etc/rc.d/rc6.d/ Reboot
s or S Single user/Maintenance mode (Slackware)
M Multiuser mode (Slackware)

4 - Management

4.1 - Get

runlevel

4.2 - OS init level

The OS Init level is promoted with the init command

[root prompt]# init 5.
Advertising

4.3 - Script init level with chkconfig

chkconfig provides a simple command-line tool for maintaining the /etc/rc[0-6].d directory hierarchy by relieving system administrators of the task of directly manipulating the numerous symbolic links in those directories.

chkconfig - updates and queries runlevel information for system services chkconfig provides a simple command-line tool for maintaining the /etc/rc[0-6].d directory hierarchy by relieving system administrators of the task of directly manipulating the numerous symbolic links in those directories.

4.3.1 - Script Services Config (Run Level, Start and Kill Position)

Each service which should be manageable by chkconfig needs two or more commented lines added to the header of the init.d script.

#!/bin/bash
# chkconfig: 345 95 20

This will instruct chkconfig to add the service:

  • to the runlevels 3, 4 and 5,
  • with a start position of 95 and a kill position of 20.

4.3.2 - List state and run level of all services which can be started by init

To get a list state and run level of all services which can be started by init

chkconfig --list
NetworkManager  0:off   1:off   2:off   3:off   4:off   5:off   6:off
acpid           0:off   1:off   2:on    3:on    4:on    5:on    6:off
anacron         0:off   1:off   2:on    3:on    4:on    5:off   6:off
apmd            0:off   1:off   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
auditd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
autofs          0:off   1:off   2:off   3:on    4:on    5:on    6:off
avahi-daemon    0:off   1:off   2:off   3:on    4:on    5:on    6:off
avahi-dnsconfd  0:off   1:off   2:off   3:off   4:off   5:off   6:off
bluetooth       0:off   1:off   2:on    3:on    4:on    5:off   6:off
capi            0:off   1:off   2:off   3:off   4:off   5:off   6:off
conman          0:off   1:off   2:off   3:off   4:off   5:off   6:off
cpuspeed        0:off   1:on    2:on    3:on    4:on    5:on    6:off
crond           0:off   1:off   2:on    3:on    4:on    5:on    6:off
cups            0:off   1:off   2:on    3:on    4:on    5:off   6:off
dnsmasq         0:off   1:off   2:off   3:off   4:off   5:off   6:off
dund            0:off   1:off   2:off   3:off   4:off   5:off   6:off
...................

4.4 - Script init level Manually

Do it with chkconfig

To be able to start a script on all init level, symbolic links should be placed in /etc/rc[0-6].d:

  • /etc/rc.d/rc0.d,
  • /etc/rc.d/rc1.d,
  • /etc/rc.d/rc2.d,
  • /etc/rc.d/rc3.d,
  • /etc/rc.d/rc5.d,
  • /etc/rc.d/rc6.d
Advertising

Documentation / Reference