Changing a Runlevel
Targets and Runlevels
In systemd, the concept of runlevels has been replaced with systemd targets to improve flexibility. For example, you can inherit an existing target and turn it into your own target by adding other services. The table below provides a complete list of runlevels and their corresponding systemd targets.
Runlevel |
systemd Target |
Description |
---|---|---|
0 |
runlevel0.target, poweroff.target |
The operating system is powered off. |
1 |
runlevel1.target, rescue.target |
The operating system is in single user mode. |
2 |
runlevel2.target, multi-user.target |
The operating system is in user-defined or domain-specific runlevel (by default, it is equivalent to runlevel 3). |
3 |
runlevel3.target, multi-user.target |
The operating system is in non-graphical multi-user mode, and can be accessed from multiple consoles or networks. |
4 |
runlevel4.target, multi-user.target |
The operating system is in user-defined or domain-specific runlevel (by default, it is equivalent to runlevel 3). |
5 |
runlevel5.target, graphical.target |
The operating system is in graphical multi-user mode. |
6 |
runlevel6.target, reboot.target |
The operating system is rebooted. |
Viewing the Default Target
To determine which target is used by default, run the following command:
systemctl get-default
Example command output:
$ systemctl get-default graphical.target
Viewing the Current Target
To list all currently loaded targets, run the following command:
systemctl list-units --type target
Example command output:
$ systemctl list-units --type target UNIT LOAD ACTIVE SUB DESCRIPTION basic.target loaded active active Basic System cryptsetup.target loaded active active Encrypted Volumes getty.target loaded active active Login Prompts graphical.target loaded active active Graphical Interface local-fs-pre.target loaded active active Local File Systems (Pre) local-fs.target loaded active active Local File Systems multi-user.target loaded active active Multi-User System network.target loaded active active Network paths.target loaded active active Paths remote-fs.target loaded active active Remote File Systems sockets.target loaded active active Sockets sound.target loaded active active Sound Card spice-vdagentd.target loaded active active Agent daemon for Spice guests swap.target loaded active active Swap sysinit.target loaded active active System Initialization time-sync.target loaded active active System Time Synchronized timers.target loaded active active Timers LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type. 17 loaded units listed. Pass --all to see loaded but inactive units, too. To show all installed unit files use 'systemctl list-unit-files'.
Changing the Default Target
To change the default target, run the following command as the root user:
systemctl set-default name.target
Example command output:
# systemctl set-default multi-user.target rm '/etc/systemd/system/default.target' ln -s '/usr/lib/systemd/system/multi-user.target' '/etc/systemd/system/default.target'
Changing the Current Target
To change the current target, run the following command as the root user:
ssystemctl isolate name.target
Example command output:
# systemctl isolate multi-user.target
Changing to Rescue Mode
To change the operating system to rescue mode, run the following command as the root user:
systemctl rescue
This command is similar to systemctl isolate rescue.target, but it also sends an informative message to all login users. To prevent systemd from sending this message, run this command with the --no-wall option:
systemctl --no-wall rescue
For example:
# systemctl rescue Broadcast message from root@localhost on pts/0 (Fri 2013-10-25 18:23:15 CEST): The system is going down to rescue mode NOW!
Changing to Emergency Mode
To change the operating system to emergency mode, run the following command as the root user:
systemctl emergency
This command is similar to systemctl isolate emergency.target, but it also sends an informative message to all login users. To prevent systemd from sending this message, run this command with the --no-wall option:
systemctl --no-wall emergency