Jump to contentJump to page navigation: previous page [access key p]/next page [access key n]
documentation.suse.com / Managing systemd targets with systemctl

Managing systemd targets with systemctl

Publication Date: 18 Apr 2024

1 Environment

This document applies to the following products and product versions:

  • SUSE Linux Enterprise Server 15 SP5, 15 SP4, 15 SP3, 15 SP2, 12 SP5

  • SUSE Linux Enterprise Server for SAP Applications 15 SP5, 15 SP4, 15 SP3, 15 SP2, 12 SP5

  • SUSE Linux Enterprise High Availability 15 SP5, 15 SP4, 15 SP3, 15 SP2, 12 SP5

  • SUSE Linux Enterprise High Performance Computing 15 SP5, 15 SP4, 15 SP3, 15 SP2

  • SUSE Linux Enterprise Desktop 15 SP5

  • SUSE Linux Enterprise Real Time 15 SP5

2 Managing systemd targets with systemctl

systemctl is the systemd command for managing target units. systemd targets are different states that your system can boot into, comparable to System V runlevels. Unlike SysV runlevels, target units are named rather than numbered. For example, the graphical.target is comparable to SysV runlevel 5, multiuser with network and a graphical environment.

Complex targets, such as graphical.target, are meta targets made by combining a subset of other targets. You may create custom targets by combining existing targets, and modifying individual targets as needed.

There are over 80 targets listed in man 7 systemd.special. The next section (Section 3, “List of the most important targets”) lists the most important targets.

3 List of the most important targets

default.target

The target that is booted by default. This is a symbolic link to another target, like graphical.target. This can be changed permanently via YaST (see xref linkend="sec-boot-runlevel-edit"). To change it for a session, rather than permanently, use the kernel parameter systemd.unit=TARGET-NAME.target at the boot prompt.

emergency.target

Starts an emergency shell on the console. Find it in your GRUB 2 menu, or enter it at the boot prompt as systemd.unit=emergency.target.

graphical.target

Starts a system with network, multiuser support, and a display manager.

halt.target

Shuts down the system.

multi-user.target

Starts a multiuser system with networking, and no graphical environment.

reboot.target

Reboots the system.

rescue.target

Starts a single-user system without networking.

To remain compatible with the System V init runlevel system, systemd provides special targets named runlevelX.target, mapped to the corresponding SysV runlevels numbered X.

To see the current target, use the command systemctl get-default.

Table 1: System V runlevels and systemd target units

System V runlevel

systemd target

Purpose

0

runlevel0.target, halt.target, poweroff.target

System shutdown

1, S

runlevel1.target, rescue.target,

Single-user mode

2

runlevel2.target, multi-user.target,

Local multiuser without remote network

3

runlevel3.target, multi-user.target,

Full multiuser with network

4

runlevel4.target

Unused/User-defined

5

runlevel5.target, graphical.target,

Full multiuser with network and display manager

6

runlevel6.target, reboot.target,

System reboot

Important
Important: systemd ignores /etc/inittab

The runlevels in a System V init system are configured in /etc/inittab. systemd does not use this configuration.

4 Commands to change targets

Use the following commands to changegit target units:

Task

systemd Command

System V init Command

Change the current target/runlevel

systemctl isolate TARGET-NAME.target

telinit X

Change to the default target/runlevel

systemctl default

n/a

Get the current target/runlevel

systemctl list-units --type=target

With systemd there is usually more than one active target. The command lists all currently active targets.

who -r

or

runlevel

persistently change the default runlevel

Use the Services Manager or run the following command:

ln -sf /usr/lib/systemd/system/ TARGET-NAME.target /etc/systemd/system/default.target

Use the Services Manager or change the line

id: X:initdefault:

in /etc/inittab

Change the default runlevel for the current boot process

Enter the following option at the boot prompt

systemd.unit= TARGET-NAME.target

Enter the desired runlevel number at the boot prompt.

Show a target's/runlevel's dependencies

systemctl show -p "Requires" TARGET-NAME.target

systemctl show -p "Wants" TARGET-NAME.target

Requires lists the hard dependencies (the ones that must be resolved), whereas Wants lists the soft dependencies (the ones that get resolved if possible).

n/a