VMware ESXi and vSphere Cluster Management
Linux Runlevels in the SysV Init System
Learn how traditional SysV Linux runlevels control services, how /etc/inittab sets the default state, and how to view or change runlevels safely.
A runlevel is a predefined operating state in the traditional System V (SysV) init model. The selected runlevel determines which services and processes should be running. For example, one runlevel may provide a networked text console, while another may start a graphical login.
Runlevels are a feature of SysV-style initialization. They are not a universal behavior implemented identically by every modern Linux system. Many current distributions use systemd, which represents system states with targets instead of traditional runlevels.
How Runlevels Work
During boot, the SysV init process reads its configuration, determines the default runlevel, and starts the services associated with that state. When the runlevel changes, init starts services that belong to the new state and stops services that no longer belong to it.
A service is a background process that provides a system function, such as networking, remote login, a database, or a graphical display manager. Service startup and shutdown actions are traditionally implemented with per-runlevel scripts and configuration. Their exact directories and naming conventions vary by distribution.
Traditional Runlevel Numbers
SysV systems conventionally use numeric runlevels from 0 through 6. Runlevels 0, 1, and 6 are special-purpose states and should not normally be selected as an everyday default. The meanings of runlevels 2, 3, and 4 are especially dependent on distribution and local configuration.
| 0 | Halt or shut down | No normal operating environment | Stops the system; do not use as a normal boot default. |
| 1 | Single-user maintenance mode | Restricted system with a limited set of services | Useful for repairs, but networking and remote access may be unavailable. |
| s/S | Single-user mode | Alternate identifiers for the maintenance state | Often treated as aliases or symbolic forms of runlevel 1. |
| 2 | Multiuser text mode | Console-oriented, non-graphical environment | Network availability varies by distribution and local setup; some traditional conventions omit networking. |
| 3 | Multiuser text mode with networking | Networked server or console environment | A common server convention, but not a guarantee on every SysV system. |
| 4 | Unused or locally defined | Depends on site configuration | Often available for administrators to define for a custom state. |
| 5 | Multiuser graphical mode | Graphical display and login environment | Common desktop/workstation convention; the display service must be configured for this state. |
| 6 | Reboot | No normal operating environment | Stops services and restarts the machine; do not use as a normal boot default. |
These descriptions are reference conventions, not identical guarantees. Before relying on a runlevel, inspect the local configuration and verify which services are enabled there. A distribution may assign different meanings to runlevels 2 through 5.
Single-User Mode and Maintenance
Single-user mode is a restricted maintenance state generally associated with runlevel 1, or with the aliases s and S. It is useful when repairing filesystems, correcting configuration, changing administrative settings, or diagnosing boot problems without starting the full collection of normal services.
Because this state may stop networking, SSH, and other services, remote administrators can lose their connection immediately after the transition. Use a physical console or an out-of-band management console before entering a maintenance-oriented runlevel. Notify users and consider the effect on production services before making the change.
/etc/inittab and the Default Runlevel
/etc/inittab is the traditional central configuration file for SysV init. It can define the default runlevel and actions to perform when runlevels change. The default runlevel is the state entered during a normal boot.
A generic configuration excerpt might look like this:
id:5:initdefault:
In this example, the initdefault entry requests runlevel 5 as the normal boot state. The exact syntax and supporting configuration are distribution-specific, so this line should be treated as an example rather than a universal modern configuration.
Other entries in /etc/inittab can describe actions associated with runlevel changes, console processes, or system initialization. Service scripts are commonly organized in distribution-specific directories such as runlevel-linked script directories, but the precise layout must be checked on the local system.
Viewing the Current and Previous Runlevel
The traditional runlevel command displays two values:
$ runlevel
N 5
The first character or value is the previous runlevel; the second is the current runlevel. In N 5, N means that no runlevel transition has occurred since boot. In the following example, the system changed from runlevel 3 to runlevel 5:
$ runlevel
3 5
| Display previous and current runlevel | runlevel | Two values: previous, then current; N means no previous transition since boot. | Read-only command. |
| Enter single-user mode | init 1 | Requests a transition to maintenance mode. | Requires administrative privileges and may terminate services and remote connectivity. |
| Inspect traditional init configuration | less /etc/inittab | Displays the default-runlevel and action entries when the file exists. | Do not assume the file is used by the active init system. |
| Display kernel and system messages | dmesg | Shows kernel messages useful for boot, device, and state-change diagnosis. | Some systems restrict access or provide messages through another logging facility. |
Changing Runlevels with init
On a SysV system, the init command requests a transition to another runlevel. Administrative privileges are required because the change can stop services, disconnect users, and alter system availability.
Entering maintenance mode
- Notify affected users and stop or protect important workloads.
- Confirm that physical or out-of-band console access is available.
- Request single-user mode:
# init 1
Perform the repair after the transition completes. Return to the normal configured operating state only after confirming that required services can be restored.
Shutdown and reboot states
Runlevel 0 requests a shutdown:
# init 0
Runlevel 6 requests a reboot:
# init 6
Both commands interrupt users and services. Use them only deliberately, with appropriate privileges and a maintenance plan.
Common Distribution Variations
Runlevel meanings are conventions. In particular, runlevels 2 through 5 can differ between distributions, releases, and administrator-maintained configurations. Runlevel 3 may be a networked multiuser text state on one system, while runlevel 5 may start a graphical display manager on another. A graphical login will not appear merely because the number 5 was selected if the display service is disabled or assigned elsewhere.
When investigating a system, distinguish the general reference meaning from its actual behavior. Inspect /etc/inittab if the system uses SysV init, review the per-runlevel service configuration, and confirm which processes are active after the transition.
SysV init Compared with Modern Init Systems
SysV init is the traditional System V-style initialization and service-management framework. Upstart uses event-driven job management, while systemd uses units and targets. A systemd target is a group of units representing a desired system state and broadly replaces the runlevel concept.
| Maintenance or rescue state | 1 or S | rescue.target | Not an exact behavioral match; dependencies and access rules differ. |
| Multiuser non-graphical state | 3 | multi-user.target | Networking and enabled services depend on the system configuration. |
| Graphical multiuser state | 5 | graphical.target | Requires a configured graphical stack and display manager. |
| Shutdown | 0 | poweroff.target | Use the native systemd procedure on a systemd host. |
| Reboot | 6 | reboot.target | Use the native systemd procedure on a systemd host. |
Some systemd installations provide compatibility mappings for commands such as runlevel and telinit, but the mapping does not make all SysV behavior identical. First identify the active init system, then use its native management tools and documentation.
Troubleshooting Runlevel Problems
The command or configuration file does not behave as expected
The likely cause is that the machine uses systemd or another init system rather than traditional SysV init. Identify the active init system and do not assume that /etc/inittab or classic runlevel commands control the machine.
Networking disappears after a transition
The selected runlevel may be configured without network services, or the distribution may assign that runlevel a different meaning. Use local console access, inspect the service configuration for that state, and return to the intended normal multiuser state.
A graphical login does not start in runlevel 5
The display manager may be disabled, not assigned to runlevel 5, or the distribution may use a different convention. Check the local runlevel service configuration. On systemd systems, investigate graphical.target instead.
The previous runlevel is shown as N
This is normal. It means that no runlevel switch has occurred since boot; it is not an error.
Remote administrators are disconnected
The transition probably stopped networking, SSH, or a related service. Plan such work from a console or out-of-band management channel, and warn users before changing the system state.
Exam-Relevant Summary
- A runlevel is an operating state in the traditional SysV init model.
- Runlevel 0 halts the system, 1 provides single-user maintenance, and 6 reboots.
- Runlevels 2 through 5 are conventions whose exact meanings vary by distribution and local configuration.
/etc/inittabtraditionally defines the default runlevel and other init actions.runlevelreports previous and current states;Nmeans no transition has occurred since boot.init 1can enter maintenance mode, but it may stop networking and disconnect remote users.- Systemd uses targets rather than traditional runlevels, although compatibility mappings may exist.
For related study, see Linux runlevels and SysV initialization.