LPIC1 (3) Runlevels

1. Runlevels of Linux System:

  • 0: Runlevel 0 is used by administrators to shut down the system.
  • 1: Single-user mode. In this mode, system services such as network interfaces, web servers, and file sharing are not started. This mode is usually used for system maintenance.
  • 2: Multiuser. On Debian-based systems, this is the default runlevel.
  • 3: On Red Hat–based systems, this is the default multiuser mode, which runs everything except the X Window System.
  • 4: Typically unused.
  • 5: On Red Hat–based systems, full multiuser mode with GUI login. Runlevel 5 is like runlevel 3, but X11 is started and a GUI login is available.
  • 6: Reboot the system.

Runleves 0 and 6 should not be the default runlevel.


2. /etc/init.d directory:

This directory contains individual startup/shutdown scripts for each service on the system.

To start, stop and restart the service manually:

$ /etc/init.d/<service name> [stop|start|restart]

Update the configuration of the service:

$ /etc/init.d/<service name> reload

3. The directories /etc/rc0.d through /etc/rc6.d

The initialization scripts in /etc/init.d are not directly executed by the init process. Instead, each of the directories /etc/rc0.d through /etc/rc6.d contains symbolic (soft) links to the scripts in the /etc/init.d directory.

The naming rules of the files in the directories /etc/rcN.d is shown bellow:

  • K and S prefixes: These letters stand for kill and start.
  • NN (Sequence number): The lowest number represents the first script executed by init, and the largest number is the last.
  • name: the name of the script being linked to.

4. Determining System’s Runlevel:

It displays the previous and current runlevel as integers.

If no runlevel change has occurred since the system was booted, the previous runlevel is displayed as the letter N.

$ runlevel
# N 5

5. Changing System’s Runlevel:

$ sync
$ sudo init <runlevel>


Reference

[1] Adam Haeder, Stephen Addison Schneiter, Bruno Gomes Pessanha, and James Stanger , LPI Linux Certification in a nutshell (3rd), O’Reilly Media (2010)

留言

熱門文章