Runlevel

The term runlevel refers to a mode of operation in one of the computer operating systems that implement Unix System V-style initialization. Conventionally, seven runlevels exist, numbered from zero to six; though up to ten, from zero to nine, may be used. S is sometimes used as a synonym for one of the levels. Only one "runlevel" is executed on bootup - run levels are not executed sequentially, i.e. either runlevel 2 OR 3 OR 4 is executed, not 2 then 3 then 4.

"Runlevel" defines the state of the machine after boot. Different runlevels are typically assigned to:

The exact setup of these configurations will vary from OS to OS, and from one Linux distribution to another. For example, runlevel 4 might be multi-user, GUI, no-server on one distribution, and nothing on another. Note the difference in the Red Hat and Slackware distributions charted in this article. However, "runlevels" do commonly follow patterns described in this article. It is best to consult the particular distribution's available user guides.

In standard practice, when a computer enters runlevel zero, it halts, 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 run levels are useful for maintenance or emergency repairs, since they usually don't offer any network services at all. The particular details of runlevel configuration differ widely among operating systems, and also among system administrators.

The runlevel system replaced the traditional /etc/rc script used in Version 7 Unix.

Standard runlevels

Standard runlevels
ID Name Description
0 JNB Shuts down the system.
S Single user mode Does not configure network interfaces or start daemons.
6 Reboot Reboots the system.

^ = Almost all systems use runlevel 1 for this purpose. This mode is intended to provide a safe environment to perform system maintenance. Originally this runlevel provided a single terminal (console) interface running a root login shell. The increasing trend towards physical access to the computer during the boot process has led to changes in this area.

Linux

The Linux operating system can make use of runlevels through the programs of the sysvinit project. After the Linux kernel has booted, the init program reads the /etc/inittab 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
ID Name Description
0 Halt Shuts down the system.
1 Single-user Mode Mode for administrative tasks.[2]
2 Multi-user Mode Does not configure network interfaces and does not export networks services.
3 Multi-user Mode with Networking Starts the system normally.
4 Not used/User-definable For special purposes.
5 Start the system normally with appropriate display manager. ( with GUI ) Same as runlevel 3 + display manager.
6 Reboot Reboots the system.

^ = The additional behavior of runlevel 1 varies greatly. All distributions provide at least one virtual terminal. Some distributions start a login shell as the superuser; some require correctly entering the superuser's password; others provide a login prompt, allowing access to any registered user.

^ = In some cases, runlevels 2 and 3 function identically; offering a Multi-user Mode with Networking.

Debian GNU/Linux

Debian, as well as most of the distributions based on it, does not make any distinction between runlevels 2 to 5, leaving that choice to the system administrator.[3]

Debian GNU/Linux runlevels[4]
ID Description
S Only run on boot (replaces /etc/rc.boot)
0 Halt
1 Single-user mode
2-5 Full Multi-user with console logins and display manager if installed
6 Reboot

Ubuntu

Ubuntu 6.10 (Edgy Eft) and later contain Upstart as a replacement for the traditional init-process, but they still use the traditional init scripts and Upstart's SysV-rc compatibility tools to start most services and emulate runlevels.

Ubuntu runlevels[5]
Code Information
0 Halt
1 Single-user mode
2 Graphical multi-user with networking
3-5 Unused but configured the same as runlevel 2
6 Reboot

Red Hat Linux and Fedora

Red Hat and most of its derivatives (such as CentOS) use runlevels like this:[6]

Red Hat Linux/Fedora runlevels
Code Information
0 Halt
1 Single-user text mode (without networking)
2 Not used (user-definable)
3 Full multi-user text mode
4 Not used (user-definable)
5 Full multi-user graphical mode (with an X-based login screen)
6 Reboot

The chkconfig utility updates and queries runlevel information for system services.[7][8]

SUSE Linux

SUSE uses a similar setup to Red Hat:

SUSE Linux runlevels
ID Description
0 Halt
1 or S Single-user mode
2 Multi-user mode without networking
3 Multi-user mode, console logins only
4 Not used/User-definable
5 Multi-user mode with display manager
6 Reboot

System administrators can modify the services that run under a specific runlevel by using YaST | System Services (runlevel), insserv or chkconfig[9] - as in the distributions based on Red Hat.

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[10]
ID Description
0 Halt
1 Single-user mode
2 Unused but configured the same as runlevel 3
3 Multi-user mode without display manager
4 Multi-user mode with display manager (X11 or a session manager)
5 Unused but configured the same as runlevel 3
6 Reboot

Gentoo Linux

Gentoo Linux runlevels[11]
ID Description
0 Halt
1 or S Single-user mode
2 Multi-user mode without networking
3 Multi-user mode
4 Aliased for runlevel 3
5 Aliased for runlevel 3
6 Reboot

Unix

System V Releases 3 and 4

System V runlevels
ID Description
0 Shut down system, power-off if hardware supports it (only available from the console)
1 Single-user mode, all filesystems unmounted but not root, all processes except console processes killed
2 Multi-user mode
3 Multi-user mode with RFS (and NFS in Release 4) filesystems exported
4 Multi-user, User-definable
5 Halt the operating system, go to firmware
6 Reboot
s, S Identical to 1, except current terminal acts as the system console

Solaris[12]

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.

Solaris runlevels
ID Description
0 Operating system halted; (SPARC only) drop to OpenBoot prompt
S Single-user mode with only root filesystem mounted (as read-only) -- Solaris 10+: svc:/milestone/single-user
1 Single-user mode with all local filesystems mounted (read-write)
2 Multi-user mode with most daemons started – Solaris 10+: svc:/milestone/multi-user
3 Multi-user mode; identical to 2 (runlevel 3 runs both /sbin/rc2 and /sbin/rc3), with filesystems exported, plus some other network services started. -- Solaris 10+: svc:/milestone/multi-user-server
4 Alternative Multi-user mode, User-definable
5 Shut down, power-off if hardware supports it
6 Reboot

HP-UX

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

AIX

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

AIX runlevels
ID Name Description
0 reserved
1 reserved
2 Normal Multi-user mode default mode

See also

References

  1. "Chapter 20. System Initialization 20.5. Run Levels". Linux Standard Base Core Specification 4.1. 2011. Retrieved 2011-04-21.
  2. "Chapter 15. Commands and Utilities 15.2. Command Behavior". Linux Standard Base Core Specification 4.1. 2011. Retrieved 2011-04-21.
  3. "Managing the Links". Debian Policy Manual. Retrieved 18 September 2014.
  4. "Debian Linux Runlevels". Retrieved 2013-06-11.
  5. "Ubuntu Runlevels (Upstart)". Retrieved 2013-06-11.
  6. "Red Hat SysV init runlevels". Red Hat Enterprise Linux 3 Reference Guide. 2003. Retrieved 2013-05-22.
  7. Ghori, Asghar (2009). Red Hat Certified Technician & Engineer: Training Guide and Administrator's Reference. La Vergne, Tennessee: Red Hat, Inc. p. 319. ISBN 9781615844302. Retrieved 2014-02-27. The chkconfig command gives you the ability to display service start and stop settings, and set a service to start and stop at appropriate rc levels.
  8. Smith, Roderick W. (2011). LPIC-1: Linux Professional Institute Certification Study Guide: (Exams 101 and 102) (2 ed.). John Wiley & Sons. p. 239. ISBN 9781118059715. Retrieved 2014-02-27. The SysV startup scripts in the runlevel directories are symbolic links back to the original script. [...] Numerous utility programs are available to help you manage these links, such as chkconfig, ntsysv, update-rc.d, and rc-update. [...T]he first two of these tools [...a]re supported on most distributions.
  9. Brown, Chris (2009). SUSE Linux. O'Reilly Media, Inc. p. 231. ISBN 9780596553623. Retrieved 2013-10-07. The unimaginatively named utility chkconfig can be used to manipulate and interrogate the Slinks and Klinks from the command line.
  10. "Slackware Linux Runlevels". Retrieved 2013-06-11.
  11. "Gentoo Linux Runlevels". Retrieved 2013-06-11.
  12. "Solaris Boot Process". Amrita Sadhukhan (Sun). Retrieved 2009-08-19.

External links