Systemd Targets
Describes how systemd targets map to run levels and how to inspect or change the system state.
By using targets, you can control systemd so that it starts only the services that are required for a specific purpose.
For example, you set the default target to multi-user.target on a production server so that the graphical user interface isn't used when the system boots. In a case where you need to troubleshoot or perform diagnostics, you might consider setting the target to rescue.target, where only root logs onto the system to run the minimum number of services.
Each run level defines the services that systemd stops or starts. As an example, systemd starts network services for multi-user.target and the X Window System for graphical.target, and stops both services for rescue.target.
System-State Targets and Equivalent Runlevel Targets shows the commonly used system-state targets and the equivalent runlevel targets.
|
System-State Targets |
Equivalent Runlevel Targets |
Description |
|---|---|---|
|
|
|
Set up a multiuser system with networking and display manager. |
|
|
|
Set up a nongraphical multiuser system with networking. |
|
|
|
Shut down and power off the system. |
|
|
|
Shut down and reboot the system. |
|
|
|
Set up a rescue shell. |
Note that runlevel* targets are implemented as symbolic links.
For more information, see the systemd.target(5) manual page.
Displaying Default and Active System-State Targets
Shows how to query the system’s default target and list all active targets with systemctl.
To display the default system-state target, use the systemctl get-default command:
systemctl get-default
graphical.target
To display the active targets on a system, use the systemctl list-units --type target command:
systemctl list-units --type target [--all]
UNIT LOAD ACTIVE SUB DESCRIPTION
basic.target loaded active active Basic System
cryptsetup.target loaded active active Local 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-online.target loaded active active Network is Online
network-pre.target loaded active active Network (Pre)
network.target loaded active active Network
nfs-client.target loaded active active NFS client services
nss-user-lookup.target loaded active active User and Group Name Lookups
paths.target loaded active active Paths
remote-fs-pre.target loaded active active Remote File Systems (Pre)
remote-fs.target loaded active active Remote File Systems
rpc_pipefs.target loaded active active rpc_pipefs.target
rpcbind.target loaded active active RPC Port Mapper
slices.target loaded active active Slices
sockets.target loaded active active Sockets
sound.target loaded active active Sound Card
sshd-keygen.target loaded active active sshd-keygen.target
swap.target loaded active active Swap
sysinit.target loaded active active System Initialization
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.
24 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
The output for a system with the graphical target active shows that this
target depends on other active targets, including network and
sound for networking and sound functionality.
Use the --all option to include inactive targets in the list.
For more information, see the systemctl(1)
and systemd.target(5) manual pages.
Changing Default and Active System-State Targets
Explains how to switch the default boot target and isolate a different target while the system is running.
Use the systemctl set-default command to change the default system-state target:
sudo systemctl set-default multi-user.target
Removed /etc/systemd/system/default.target.
Created symlink /etc/systemd/system/default.target → /usr/lib/systemd/system/multi-user.target
This command changes the target to which the default target is linked, but doesn't change the state of the system.
To change the current active system target, use the systemctl isolate command, for example:
sudo systemctl isolate multi-user.target
For more information, see the systemctl(1)
manual page.