Runlevel Explained

A runlevel is a mode of operation in the computer operating systems that implements Unix System V-style initialization. Conventionally, seven runlevels exist, numbered from zero to six. S is sometimes used as a synonym for one of the levels. Only one runlevel is executed on startup; run levels are not executed one after another (i.e. only runlevel 2, 3, or 4 is executed, not more of them sequentially or in any other order).

A runlevel defines the state of the machine after boot. Different runlevels are typically assigned (not necessarily in any particular order) to the single-user mode, multi-user mode without network services started, multi-user mode with network services started, system shutdown, and system reboot system states. The exact setup of these configurations varies between operating systems and Linux distributions. For example, runlevel 4 might be a multi-user GUI no-server configuration on one distribution, and nothing on another. Runlevels commonly follow the general patterns described in this article; however, some distributions employ certain specific configurations.

In standard practice, when a computer enters runlevel zero, it shuts off, and when it enters runlevel six, it reboots. The intermediate runlevels (1–5) differ in terms of which drives are mounted and which network services are started. Default runlevels are typically 3, 4, or 5. Lower runlevels are useful for maintenance or emergency repairs, since they usually offer no network services at all. The particular details of runlevel configuration differ widely among operating systems, and also among system administrators.

In various Linux distributions, the traditional script used in the Version 7 Unix was first replaced by runlevels and then by systemd states on most major distributions.

Standard runlevels

Standard runlevels
IDNameDescription
0OffTurns off the device.
1Single user modeDoes not configure network interfaces or start daemons.
6RebootReboots the device.

Linux

Although systemd is,, used by default in most major Linux distributions, runlevels can still be used through the means provided by the sysvinit project. After the Linux kernel has booted, the program reads the file to determine the behavior for each runlevel. Unless the user specifies another value as a kernel boot parameter, the system will attempt to enter (start) the default runlevel.

Linux Standard Base specification

Systems conforming to the Linux Standard Base (LSB) need not provide the exact run levels given here or give them the meanings described here, and may map any level described here to a different level which provides the equivalent functionality.[1]

LSB 4.1.0
IDNameDescription
0OffTurns off the device.
1Single-user modeMode for administrative tasks.[2]
2Multi-user modeDoes not configure network interfaces and does not export networks services.
3Multi-user mode with networkingStarts the system normally.
4Not used/user-definableFor special purposes.
5Full modeSame as runlevel 3 + display manager.
6RebootReboots the device.

Slackware Linux

Slackware Linux uses runlevel 1 for maintenance, as on other Linux distributions; runlevels 2, 3 and 5 identically configured for a console (with all services active); and runlevel 4 adds the X Window System.

Slackware Linux runlevels[3]
IDDescription
0Off
1Single-user mode
2Unused but configured the same as runlevel 3
3Multi-user mode without display manager
4Multi-user mode with display manager (X11 or a session manager)
5Full mode
6Reboot

Gentoo Linux

Gentoo Linux runlevels[4]
IDDescription
0Off
1 or SSingle-user mode
2Multi-user mode without networking.
3Multi-user mode
4Aliased for runlevel 3
5Full mode
6Reboot

Debian GNU/Linux

Debian GNU/Linux runlevels[5]
IDDescription
0Off
1Recovery mode
2,3,4Partial mode
5Full mode
6Reboot

Unix

System V Releases 3 and 4

System V runlevels
IDDescription
0Off
1Single-user mode, all filesystems unmounted but not root, all processes except console processes killed
2Multi-user mode
3Multi-user mode with RFS (and NFS in Release 4) filesystems exported
4Multi-user, User-definable
5Go to firmware
6Reboot
s, SIdentical to 1, except current terminal acts as the system console

Solaris

Starting from Solaris 10, SMF (Service Management Facility) is used instead of SVR4 run levels. The latter are emulated to preserve compatibility with legacy startup scripts.[6]

Solaris runlevels!ID!Description
0On SPARC systems, it returns to firmware, while on x86 systems, it shuts off the machine. If the user presses Enter, the system reboots.
SSingle-user mode with only root filesystem mounted (as read-only) -- Solaris 10+: svc:/milestone/single-user
1Single-user mode with all local filesystems mounted (read-write)
2Multi-user mode with most daemons started – Solaris 10+: svc:/milestone/multi-user
3Multi-user mode; identical to 2 (runlevel 3 runs both and), with filesystems exported, plus some other network services started. -- Solaris 10+: svc:/milestone/multi-user-server
4Alternative Multi-user mode, User-definable
5Off
6Reboot

HP-UX

HP-UX runlevels
IDDescription
0Off
SSingle-user mode, booted to system console only, with only root filesystem mounted (as read-only)
sSingle-user mode, identical to S except the current terminal acts as the system console
1Single-user mode with local filesystems mounted (read-write)
2Multi-user mode with most daemons started and Common Desktop Environment launched
3Identical to runlevel 2 with NFS exported
4Multi-user mode with VUE started instead of CDE
5, 6Not used/User-definable

AIX

AIX does not follow the System V R4 (SVR4) runlevel specification, with runlevels from 0 to 9 available, as well as from a to c (or h). 0 and 1 are reserved, 2 is the default normal multi-user mode and runlevels from 3 to 9 are free to be defined by the administrator. Runlevels from a to c (or h) allow the execution of processes in that runlevel without killing processes started in another.

AIX runlevels
IDNameDescription
0reserved
1reserved
2Normal Multi-user modedefault mode

The S, s, M and m runlevels are not true runlevels, but are used to tell the init command to enter maintenance mode. When the system enters maintenance mode from another runlevel, only the system console is used as the terminal.

See also

External links

Notes and References

  1. Web site: Chapter 20. System Initialization 20.5. Run Levels . Linux Standard Base Core Specification 4.1 . 2011 . 2011-04-21.
  2. Web site: Chapter 15. Commands and Utilities 15.2. Command Behavior . Linux Standard Base Core Specification 4.1 . 2011 . 2011-04-21.
  3. Web site: Slackware Linux Runlevels. 2013-06-11.
  4. Web site: Gentoo Linux Runlevels. 2013-06-11.
  5. Web site: Debian runlevel manpage. 2021-10-31.
  6. Web site: Solaris Boot Process. Amrita Sadhukhan. Sun. 2009-08-19. 2013-07-09. https://web.archive.org/web/20130709063354/https://blogs.oracle.com/boot/entry/amrita_sadhukhan. dead.