Runlevel

Last updated

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).

Contents

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 /etc/rc 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.
1 Single user mode Does not configure network interfaces or start daemons. [lower-alpha 1]
6RebootReboots the device.

Linux

Although systemd is, as of 2016, 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 /sbin/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
IDNameDescription
0OffTurns off the device.
1Single-user modeMode for administrative tasks. [2] [lower-alpha 2]
2Multi-user modeDoes not configure network interfaces and does not export networks services. [lower-alpha 3]
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
IDDescription
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 /sbin/rc2 and /sbin/rc3), 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

Notes

  1. 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.
  2. 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.
  3. In some cases, runlevels 2 and 3 function identically, offering a multi-user mode with networking.

Related Research Articles

<span class="mw-page-title-main">Unix shell</span> Command-line interpreter for Unix operating system

A Unix shell is a command-line interpreter or shell that provides a command line user interface for Unix-like operating systems. The shell is both an interactive command language and a scripting language, and is used by the operating system to control the execution of the system using shell scripts.

In computing, the superuser is a special user account used for system administration. Depending on the operating system (OS), the actual name of this account might be root, administrator, admin or supervisor. In some cases, the actual name of the account is not the determining factor; on Unix-like systems, for example, the user with a user identifier (UID) of zero is the superuser, regardless of the name of that account; and in systems which implement a role based security model, any user with the role of superuser can carry out all actions of the superuser account. The principle of least privilege recommends that most users and applications run under an ordinary account to perform their work, as a superuser account is capable of making unrestricted, potentially adverse, system-wide changes.

<span class="mw-page-title-main">Daemon (computing)</span> Computer program that runs as a background process

In multitasking computer operating systems, a daemon is a computer program that runs as a background process, rather than being under the direct control of an interactive user. Traditionally, the process names of a daemon end with the letter d, for clarification that the process is in fact a daemon, and for differentiation between a daemon and a normal computer program. For example, syslogd is a daemon that implements system logging facility, and sshd is a daemon that serves incoming SSH connections.

Fast user switching is a feature of a multi-user operating system which allows users to switch between user accounts without quitting applications and logging out.

udev is a device manager for the Linux kernel. As the successor of devfsd and hotplug, udev primarily manages device nodes in the /dev directory. At the same time, udev also handles all user space events raised when hardware devices are added into the system or removed from it, including firmware loading as required by certain devices.

Unix-like operating systems identify a user by a value called a user identifier, often abbreviated to user ID or UID. The UID, along with the group identifier (GID) and other access control criteria, is used to determine which system resources a user can access. The password file maps textual user names to UIDs. UIDs are stored in the inodes of the Unix file system, running processes, tar archives, and the now-obsolete Network Information Service. In POSIX-compliant environments, the command-line command id gives the current user's UID, as well as more information such as the user name, primary user group and group identifier (GID).

init UNIX system component

In Unix-based computer operating systems, init is the first process started during booting of the operating system. Init is a daemon process that continues running until the system is shut down. It is the direct or indirect ancestor of all other processes and automatically adopts all orphaned processes. Init is started by the kernel during the booting process; a kernel panic will occur if the kernel is unable to start it. Init is typically assigned process identifier 1.

launchd is an init and operating system service management daemon created by Apple Inc. as part of macOS to replace its BSD-style init and SystemStarter. There have been efforts to port launchd to FreeBSD and derived systems.

<span class="mw-page-title-main">Safe mode</span> Computer operating system diagnostic mode

Safe mode is a diagnostic mode of a computer operating system (OS). It can also refer to a mode of operation by application software. Safe mode is intended to help fix most, if not all, problems within an operating system. It is also widely used for removing rogue security software.

Service Management Facility (SMF) is a feature of the Solaris operating system as of version 10 and OpenSolaris-descendant illumos with its illumos distributions, that creates a supported, unified model for services and service management on each Solaris or illumos system and replaces init.d scripts. SMF introduces:

The booting process of Windows NT includes Windows NT 4.0, Windows 2000, Windows XP and Windows Server 2003. In Windows Vista and later, this process has changed significantly; see Windows NT 6 startup process for information about what has changed.

Upstart is a discontinued event-based replacement for the traditional init daemon—the method by which several Unix-like computer operating systems perform tasks when the computer is started. It was written by Scott James Remnant, a former employee of Canonical Ltd. In 2014, Upstart was placed in maintenance mode, and other init daemons, such as systemd, were recommended in place of Upstart. Ubuntu moved away from Upstart with the release of version 15.04 in favor of migrating to systemd. As of March 2023, there have been no updates released for Upstart since September 2014.

Single-user mode is a mode in which a multiuser computer operating system boots into a single superuser. It is mainly used for maintenance of multi-user environments such as network servers. Some tasks may require exclusive access to shared resources, for example running fsck on a network share. This mode can also be used for security purposes – network services are not run, eliminating the possibility of outside interference. On some systems a lost superuser password can be changed by switching to single-user mode, but not asking for the password in such circumstances is viewed as a security vulnerability.

chsh is a command on Unix-like operating systems that is used to change a login shell. Users can either supply the pathname of the shell that they wish to change to on the command line, or supply no arguments, in which case chsh allows the user to change the shell interactively.

The multi-stage booting process of Linux is in many ways similar to the BSD and other Unix-style boot processes, from which it derives.

<span class="mw-page-title-main">Salix OS</span> Linux distribution

Salix OS is a multi-purpose Linux distribution based on Slackware.

<span class="mw-page-title-main">Linux console</span> Console of the Linux kernel

The Linux console is a system console internal to the Linux kernel. A system console is the device which receives all kernel messages and warnings and which allows logins in single user mode. The Linux console provides a way for the kernel and other processes to send text output to the user, and to receive text input from the user. The user typically enters text with a computer keyboard and reads the output text on a computer monitor. The Linux kernel supports virtual consoles – consoles that are logically separate, but which access the same physical keyboard and display. The Linux console are implemented by the VT subsystem of the Linux kernel, and do not rely on any user space software. This is in contrast to a terminal emulator, which is a user space process that emulates a terminal, and is typically used in a graphical display environment.

systemd Suite of system components for Linux

systemd is a software suite that provides an array of system components for Linux operating systems. The main aim is to unify service configuration and behavior across Linux distributions. Its primary component is a "system and service manager" – an init system used to bootstrap user space and manage user processes. It also provides replacements for various daemons and utilities, including device management, login management, network connection management, and event logging. The name systemd adheres to the Unix convention of naming daemons by appending the letter d. It also plays on the term "System D", which refers to a person's ability to adapt quickly and improvise to solve problems.

<span class="mw-page-title-main">OpenRC</span> Init system for Unix-like computer operating systems

OpenRC is a dependency-based init system for Unix-like computer operating systems. It was created by Roy Marples, a NetBSD developer who was also active in the Gentoo project. It became more broadly adopted as an init system outside of Gentoo following the decision by some Linux distributions not to adopt systemd.

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. "Slackware Linux Runlevels" . Retrieved 2013-06-11.
  4. "Gentoo Linux Runlevels" . Retrieved 2013-06-11.
  5. "Debian runlevel manpage" . Retrieved 2021-10-31.
  6. Amrita Sadhukhan. "Solaris Boot Process". Sun. Archived from the original on 2013-07-09. Retrieved 2009-08-19.