Linux Runlevels and SysV Init
Learn traditional Linux runlevels, SysV init, /etc/inittab, checking the active runlevel, changing modes, and safely entering maintenance or reboot states.
What Is a Linux Runlevel?
A runlevel is a predefined operating state managed by the traditional System V initialization, or SysV init, system. Each state represents a broad combination of running processes and services.
When the system enters a runlevel, SysV init uses that level's service-start and service-stop scripts. These scripts determine which services should be started and which should be stopped.
A runlevel is broader than an individual service state. For example, a web server being active describes one service. Runlevel 3 describes a complete multiuser operating mode that may include networking, login services, logging, and many other processes.
Important terminology
- SysV init: The traditional System V-style Linux initialization and service-management framework.
- init: The traditional first userspace process. It controls system startup and transitions between runlevels.
- single-user mode: A restricted, maintenance-oriented operating state, conventionally associated with runlevel 1, S, or s.
- multiuser mode: An operating state designed to support multiple users and a broader collection of services.
- graphical mode: A multiuser state that starts a graphical login or desktop environment.
Scope: Traditional SysV Init
Numeric runlevels primarily belong to SysV init. Many current Linux distributions use systemd or another initialization system instead. systemd uses targets, while Upstart uses a different event and job model.
As a result, numeric runlevels do not work identically on every current Linux distribution. The meanings of levels 2 through 5 may be changed by the distribution or by an administrator. Always check the local documentation before relying on a particular mapping.
For background on the broader Linux environment, see Linux and Linux file structure.
Traditional Linux Runlevel Reference
The following table shows the commonly taught SysV convention. It is a reference model, not a guarantee for every distribution.
| Runlevel | Typical purpose | Service and access characteristics | Important cautions |
|---|---|---|---|
| 0 | Halt or shutdown | Stops normal services and powers down the system. | Destructive operational action; use deliberately. |
| 1, S, s | Single-user maintenance | Starts a limited service set, usually for local administration and repair. | Networking, remote login, and ordinary user sessions may be unavailable. |
| 2 | Distribution-defined; commonly multiuser text mode without networking | Supports multiple users with a reduced service set in the common convention. | Exact behavior varies by distribution and local configuration. |
| 3 | Multiuser text mode with networking | Usually provides consoles, networking, remote login, and non-graphical services. | Do not assume every distribution assigns level 3 this way. |
| 4 | Distribution-defined; commonly unused | Available for local customization or a special operating state. | May have a meaningful administrator-defined purpose. |
| 5 | Multiuser graphical mode | Commonly starts networking, multiuser services, and a graphical login or desktop. | Graphical behavior depends on the distribution and configured scripts. |
| 6 | Reboot | Stops services and restarts the system. | Destructive operational action; active work and sessions can be interrupted. |
Levels 0, 1, and 6 have special or reserved roles. Use them only when you understand the effect and have suitable access to recover from an unexpected result.
How SysV Init Uses /etc/inittab
/etc/inittab is the primary configuration file for conventional SysV init systems. It can define the default runlevel selected after boot and associate actions or processes with particular runlevels.
The default runlevel is the level that init enters automatically during boot. A typical illustrative entry is:
id:5:initdefault:In this entry, the fields are separated by colons. The value 5 identifies the default runlevel. This is only an example; the configured value is system-specific.
Other entries can specify processes or actions that apply to selected runlevels. For example, a fragment might look like this:
# Illustrative only; exact entries vary by distribution
id:5:initdefault:
si::sysinit:/etc/rc.d/rc.sysinit
l3:3:wait:/etc/rc.d/rc 3
l5:5:wait:/etc/rc.d/rc 5The exact scripts, paths, identifiers, and actions differ between systems. Do not copy an example into a production /etc/inittab without checking the local init implementation and documentation.
Checking the Current Runlevel
Use the runlevel command to display the previous and current SysV runlevels:
runlevelThe command normally prints two values:
- The first value is the previous runlevel.
- The second value is the current runlevel.
An N in the previous-runlevel position means that no prior runlevel transition has been recorded since startup.
| Sample output | Previous state | Current state | Interpretation |
|---|---|---|---|
N 5 | No previous transition recorded | Runlevel 5 | The system is currently in level 5 and has not recorded an earlier runlevel change since boot. |
3 5 | Runlevel 3 | Runlevel 5 | The system moved from level 3 to level 5; level 5 is now active. |
dmesg can help inspect kernel and boot messages while investigating initialization behavior, but it does not itself report the current runlevel.
Changing Runlevels
The traditional init process can be asked to transition to a numbered runlevel. For example, an administrator can request single-user maintenance mode with:
init 1Changing to a different level causes SysV init to compare the current and requested states, then start and stop services according to the configured service scripts for the destination level.
Runlevel changes generally require administrative privileges. On systems where direct root access is restricted, use the approved administrative mechanism for that host.
Maintenance example
- Confirm that you have local console or physical access before entering a restricted mode.
- Notify users and stop or protect applications that may have unsaved data.
- Request the maintenance level with
init 1. - Perform the required local maintenance.
- Return to the normal documented multiuser runlevel when the work is complete.
Remote administration can be interrupted when entering runlevel 1 or another reduced-service state. Networking, the SSH service, the remote user's session, or all three may stop. Confirm a local console or an approved recovery path before making the change.
SysV Runlevels and Modern systemd Equivalents
systemd targets are approximate conceptual equivalents, not guaranteed numeric aliases. A systemd target groups units, which are systemd's managed service and resource objects.
| Traditional runlevel | Typical historical role | Approximate systemd target concept | Portability note |
|---|---|---|---|
| 1 | Single-user maintenance | rescue.target | Behavior and access controls depend on the systemd configuration. |
| 3 | Multiuser text mode with networking | multi-user.target | Not every system maps legacy level 3 to this target in the same way. |
| 5 | Multiuser graphical mode | graphical.target | Requires a configured graphical login environment. |
| 0 | Halt or shutdown | poweroff.target | Use the native systemd shutdown tools on systemd hosts. |
| 6 | Reboot | reboot.target | Use the native systemd reboot tools on systemd hosts. |
Troubleshooting Runlevel Problems
runlevel is unavailable or behaves unexpectedly
The host may use systemd or another non-SysV init implementation. Identify the active init system and use its native service and boot-target tools. Do not assume that a legacy command has the same meaning everywhere.
The selected runlevel does not provide expected networking or graphics
Levels 2 through 5 are not standardized across all distributions and may have been customized. Review the local /etc/inittab, service-script configuration, and distribution documentation.
A remote session disconnects after changing levels
The transition may have stopped networking, the remote-login service, or the user session. Perform this type of maintenance from a local console or verify an approved recovery method first.
The system shuts down or restarts
Runlevel 0 was selected for shutdown or runlevel 6 was selected for reboot. Verify the intended level before executing an init command.
/etc/inittab is missing
The host likely does not use a conventional SysV init layout. Do not create an inittab solely to imitate SysV. Use the configuration model of the active init system instead.
Exam- and Administration-Relevant Notes
- Runlevels are broad SysV operating modes, not individual service states.
- The traditional convention assigns 0 to halt, 1/S/s to single-user maintenance, 5 to graphical multiuser operation, and 6 to reboot.
- Levels 2, 3, and 4 are distribution- or administrator-defined, although common teaching often associates them with no-network text mode, networked text mode, and unused, respectively.
/etc/inittabcan contain the default-runlevel entry and runlevel-specific actions.runlevelreports previous then current level. For example,3 5means the system moved from level 3 to level 5.- Administrative privileges and a reliable local or recovery console are important before changing runlevels.