Change Runlevels in Linux with init and systemctl
Learn what Linux runlevels mean, how SysV init changes operating modes, and how to use systemd targets safely with systemctl.
Linux can operate in different system-wide modes. A server may run services and provide text logins, while a workstation may also start a graphical login screen. The mechanism used to select these modes depends on the system's init system.
The traditional mechanism is SysV init, which uses numbered runlevels. Most current Linux distributions use systemd, which uses named targets instead. This lesson explains both approaches and shows how to change the current mode without confusing a temporary change with a boot-time default.
What the init system does
The init system is the first major user-space service manager started after the Linux kernel boots. It starts and supervises services such as networking, logging, scheduled tasks, login services, and display managers. It also handles process cleanup and responds to system-wide state changes.
On a traditional SysV system, the initialization process is normally PID 1. PID means process identifier, and PID 1 is the first user-space process started by the kernel. On a modern system, systemd commonly occupies PID 1. The command named init may still exist as a compatibility interface, but it may ultimately forward requests to systemd rather than use traditional SysV behavior.
Init configuration determines the operating mode selected during boot and the actions taken when the mode changes. In SysV init, this configuration is based on runlevels and startup scripts. In systemd, it is based on targets and unit dependencies.
Identify the init system
Inspect PID 1 before using a command that assumes a particular init design:
ps -p 1 -o pid,comm,args=
A result whose command is systemd indicates a systemd host. Another command, such as init or a distribution-specific init implementation, may indicate a non-systemd system. This check is useful, but always consider the actual commands and targets available on the host.
What is a runlevel?
A runlevel is a predefined numbered operating state in SysV init. Each state selects a collection of startup and shutdown actions. Those actions determine which services run and whether the machine offers a restricted maintenance environment, text-based multiuser operation, or a graphical login environment.
Runlevels are conventions, not universal standards with identical meanings everywhere. Distribution defaults, installed packages, startup scripts, and local administrator configuration can change the behavior. A runlevel described as graphical on one older distribution may be unused or configured differently on another.
Traditional SysV runlevel meanings
| Runlevel | Typical purpose | Service and interface behavior | Portability notes |
|---|---|---|---|
| 0 | Halt or power off | Stops services and proceeds toward shutting down the machine. | Disruptive everywhere; do not enter casually. |
| 1, S, s | Single-user or maintenance mode | Starts a restricted environment with few services and limited user access. | The exact capitalization and aliases vary. |
| 2 | Distribution-dependent multiuser mode | May provide multiuser operation, historically sometimes without networking. | Its meaning differs substantially between distributions. |
| 3 | Text-based multiuser mode | Often starts networking and services with text consoles but no graphical login. | Common on many SysV configurations, but not guaranteed. |
| 4 | Unused or reserved | Often available for local administrator customization. | May have a site-specific meaning. |
| 5 | Graphical multiuser mode | Often starts a display manager and a graphical login or desktop. | Common on workstation-oriented configurations; servers may lack graphics. |
| 6 | Reboot | Stops services and restarts the machine. | Disruptive everywhere; use an explicit reboot command when possible. |
Runlevels 0 and 6 are not ordinary operating modes: they power off or reboot the host. Save work, notify users, and use a planned maintenance window before requesting either one.
Change runlevels on a SysV init system
The traditional init command accepts a runlevel number. Root privileges are normally required:
sudo init 1
This requests single-user or maintenance mode. Normal services may stop, logged-in users may be disconnected, and networking or SSH may become unavailable. Use a local console or reliable out-of-band access before making this transition.
On a legacy workstation where runlevel 5 is configured as graphical multiuser mode, the transition back is:
sudo init 5
Do not assume that runlevel 5 always starts a desktop. Confirm the local configuration first. Some systems use another runlevel for graphical operation, and some servers have no display manager or desktop installed.
telinit is a historical companion command that requests the same type of transition on systems using traditional init:
sudo telinit 1
Use the command supported by the host. On systemd systems, prefer systemctl and named targets instead of relying on compatibility behavior.
Inspect the current and previous runlevel
These commands are commonly available on SysV-compatible systems:
runlevel
who -r
runlevel usually prints the previous and current runlevels. A previous value of N means there was no recorded previous runlevel. who -r displays runlevel information along with related system status.
SysV init configuration and /etc/inittab
/etc/inittab is the traditional SysV init configuration file when the distribution supports and uses it. It can define the default runlevel and actions that init performs when a runlevel changes. A typical entry might look like this:
id:3:initdefault:
This example represents a default runlevel of 3, although the correct syntax and surrounding configuration depend on the specific init implementation. Other entries can define console handling, respawn behavior, and runlevel-specific actions.
After editing configuration on a system that uses /etc/inittab, init may be able to reread it without a full reboot. The exact signal or command is implementation-dependent, so consult the local documentation before reloading. Many modern distributions no longer use /etc/inittab as their primary init configuration; changing this file on such a system may have no effect.
systemd targets: the modern equivalent
systemd is an init and service manager used by many current Linux distributions. Instead of numbered runlevels, it uses targets. A target is a synchronization unit representing a desired collection of services and system conditions. Targets are similar to runlevels, but they are named and integrated with systemd's dependency system.
| Traditional concept | Common SysV runlevel | Closest systemd target | Recommended modern command | Important caveat |
|---|---|---|---|---|
| Maintenance mode | 1, S, or s | rescue.target | sudo systemctl isolate rescue.target | Networking and other services may stop; remote access can be lost. |
| Non-graphical multiuser mode | 3 | multi-user.target | sudo systemctl isolate multi-user.target | Exact services depend on enabled units and local dependencies. |
| Graphical multiuser mode | 5 | graphical.target | sudo systemctl isolate graphical.target | A desktop and display manager must be installed and configured. |
| Power off | 0 | poweroff.target | sudo systemctl poweroff | Use the explicit poweroff action rather than treating runlevel 0 as routine. |
| Reboot | 6 | reboot.target | sudo systemctl reboot | Use the explicit reboot action for clarity and graceful shutdown. |
Switch the current systemd target
systemctl isolate changes the active system state immediately. It starts the requested target and stops units that are not required by that target:
sudo systemctl isolate rescue.targetsudo systemctl isolate multi-user.targetsudo systemctl isolate graphical.target
For example, switching from a graphical session to multi-user.target normally stops the display manager and graphical session while leaving the host in non-graphical multiuser operation. Switching back requires a configured graphical environment:
sudo systemctl isolate graphical.target
Inspect available targets with:
systemctl list-units --type=target --all
View and change the boot default
The default target is the target systemd selects automatically at the next boot. View it with:
systemctl get-default
Configure a server to boot into non-graphical multiuser operation:
sudo systemctl set-default multi-user.target
Configure a workstation to boot into graphical multiuser operation:
sudo systemctl set-default graphical.target
set-default changes future boot behavior. It does not necessarily switch the currently running session. Use isolate when an immediate runtime transition is intended.
Practical examples
Move a legacy SysV system into maintenance mode
- Check the current state with
runlevelorwho -r. - Save active work and notify other users.
- Confirm that you have a local console or dependable out-of-band access.
- Request maintenance mode with
sudo init 1.
Expect normal services to stop. The network or SSH daemon may be unavailable, so do not perform this operation over an SSH connection unless you have another recovery path.
Return a legacy workstation to graphical mode
First confirm that the system uses SysV runlevels and that its local configuration assigns runlevel 5 to graphical operation. Then run:
sudo init 5
If no graphical login appears, the distribution may use a different mapping, or it may not have a display manager and desktop installed.
Switch a systemd host from graphical to text mode
sudo systemctl isolate multi-user.target
The graphical session and display manager may stop. To return to graphical operation when it is configured:
sudo systemctl isolate graphical.target
Set a server to boot without a graphical desktop
- Check the current boot default with
systemctl get-default. - Set the future default with
sudo systemctl set-default multi-user.target. - Reboot during a planned maintenance window if you want to test the boot behavior.
This changes the next boot's mode; it does not by itself stop the current graphical session.
Restart or power off safely
sudo systemctl reboot
sudo systemctl poweroff
These explicit commands communicate the intended action more clearly than numeric runlevels and allow systemd to perform its normal shutdown ordering.
Safety and operational considerations
| Check | Why it matters | Example command or action |
|---|---|---|
| Determine the init system | SysV commands and systemd targets are not interchangeable in every environment. | ps -p 1 -o pid,comm,args= |
| Check the current state | You need to know whether a change is necessary and what it may stop. | runlevel, who -r, or the active systemd target information. |
| Confirm remote-access implications | Maintenance targets can stop networking or SSH. | Use a local console or out-of-band console before isolating a restricted target. |
| Verify graphical target availability | A graphical target does not guarantee that a desktop exists. | systemctl list-units --type=target --all and inspect the display manager. |
| Save work and notify users | System-wide transitions can terminate sessions and interrupt services. | Schedule a maintenance window and communicate the expected interruption. |
Always distinguish an immediate runtime transition from a default change for the next boot. systemctl isolate changes the current state. systemctl set-default changes the boot choice. On a remote machine, entering rescue-style maintenance mode without console access can leave you unable to reconnect.
Distribution and environment differences
- Older distributions do not all assign the same meaning to runlevels 2, 3, 4, and 5.
- A server may expose
graphical.targeteven when no desktop, display manager, or physical display is installed. - Containers often do not run a full init system as PID 1. Their available commands and targets may be limited.
- Minimal installations, WSL-like environments, and systems using a non-systemd init may not support the same systemctl commands.
- Systemd compatibility mappings can make numeric runlevel commands appear to work without providing traditional SysV semantics.
Troubleshooting
The init command is unsupported or behaves unexpectedly
The host may use systemd, or the requested runlevel may have no configured meaning. Inspect PID 1, then use the appropriate systemd target if systemd is active. If the host truly uses SysV init, inspect its local configuration and, where applicable, /etc/inittab.
Graphical mode does not show a desktop
Possible causes include a missing desktop environment, a missing or failed display manager, an incorrectly configured graphical.target, or a server or virtual environment without a usable display. Check the default target, inspect the display-manager service, and use multi-user.target when graphical operation is unnecessary.
The SSH session disconnects during maintenance
The selected runlevel or target probably stopped networking or the SSH service. Recover through a local or out-of-band console. Avoid using a restricted rescue target remotely unless you have a tested way to regain access.
The system boots to a text console instead of the desktop
Check the boot default with systemctl get-default. If it is multi-user.target, the configured default intentionally selects text mode. If it is graphical.target, investigate the display manager and boot logs. Set graphical.target as the default only after confirming the graphical components are installed and working.
Documentation does not match the local runlevel behavior
Runlevel conventions vary by distribution and local administrator configuration. Treat numeric mappings as common conventions rather than guarantees. Inspect the actual init configuration or use systemd's target information on a systemd host.
Exam-relevant summary
- Traditional SysV init commonly runs as PID 1 and uses numbered runlevels.
- Runlevel 1, S, or s generally means restricted single-user maintenance; 3 commonly means text multiuser; 5 commonly means graphical multiuser; 0 powers off; and 6 reboots.
/etc/inittabis the traditional SysV configuration file, but many current systems do not use it.- Systemd replaces runlevel concepts with targets:
rescue.target,multi-user.target, andgraphical.targetare the most common operating-state equivalents. systemctl isolatechanges the current state, whilesystemctl set-defaultchanges the mode selected at the next boot.- Use
systemctl rebootandsystemctl powerofffor explicit, graceful restart and shutdown actions.
For broader command-line and Linux administration practice, see Linux and Bourne Again Shell Bash.