2 of 4

Services, Targets and BootLesson 2 of 4

Targets, the default target and power control

Understand what a target is, set the default one, switch on a running system, and shut down or reboot safely.

  • systemctl get-default
  • systemctl set-default
  • systemctl isolate
  • systemctl list-dependencies
  • reboot
  • poweroff
  • shutdown
  • systemctl rescue
  • who

35 min5 exercises

After this lesson you can

  • Explain what a target is and name the ones that matter: multi-user, graphical, rescue, emergency.
  • Read and set the default target, and switch targets on a running system.
  • Reboot, power off and schedule a shutdown with a warning to logged-in users.

The idea

A target is a named synchronisation point: a group of units that must be running for the system to count as “in that state”. Where older Linux had run levels, systemd has targets, which are more flexible because they are just units that depend on other units.

TargetMeaningOld run level
poweroff.targetShut the machine down0
rescue.targetSingle-user mode: base system and file systems mounted, root shell, no network1
emergency.targetMinimal: root file system read-only, almost nothing elsen/a
multi-user.targetFull text-mode system with networking3
graphical.targetmulti-user plus a graphical login5
reboot.targetReboot6

The default target is what the machine reaches at boot. It is a symlink, /etc/systemd/system/default.target, and servers normally use multi-user.target.

Two commands that are easy to confuse:

CommandChangesTakes effect
systemctl set-default TARGETThe default for future bootsNext boot
systemctl isolate TARGETThe current state, stopping what the target does not includeImmediately

isolate is how you drop to rescue.target for maintenance and come back, and it stops services that aren’t part of the target, including your SSH session if the target has no network. Do it from the console.

rescue.target and emergency.target both need the root password. With the account locked or the password forgotten you can’t enter them from a running system; that is what the next two lessons solve from the boot loader.

Try it

systemctl get-default
systemctl list-units --type=target --no-pager | head -6
multi-user.target
  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
  local-fs.target      loaded active active Local File Systems
  multi-user.target    loaded active active Multi-User System

Change the default

sudo systemctl set-default graphical.target
ls -l /etc/systemd/system/default.target
Removed '/etc/systemd/system/default.target'.
Created symlink '/etc/systemd/system/default.target' → '/usr/lib/systemd/system/graphical.target'.
lrwxrwxrwx. 1 root root 48 Nov  3 11:58 /etc/systemd/system/default.target -> /usr/lib/systemd/system/graphical.target
sudo systemctl set-default multi-user.target
systemctl get-default
Removed '/etc/systemd/system/default.target'.
Created symlink '/etc/systemd/system/default.target' → '/usr/lib/systemd/system/multi-user.target'.
multi-user.target

What a target pulls in

systemctl list-dependencies multi-user.target --no-pager | head -8
multi-user.target
● ├─auditd.service
● ├─chronyd.service
● ├─crond.service
● ├─firewalld.service
● ├─NetworkManager.service
● ├─sshd.service
● ├─basic.target

Power control

All of these are the same engine: reboot, poweroff and halt are symlinks to systemctl.

sudo systemctl reboot
sudo systemctl poweroff
sudo shutdown -r +10 "Maintenance reboot"
sudo shutdown -c
Shutdown scheduled for Tue 2026-11-03 12:12:00 +03, use 'shutdown -c' to cancel.

shutdown -r reboots, -h or -P powers off, +N is N minutes from now, and a time such as 23:00 is also accepted. The message goes to every logged-in terminal and new logins are blocked in the last five minutes. shutdown -c cancels. Check with who before an unscheduled reboot to see who you’d interrupt.

Going further

systemctl rescue and systemctl emergency are shortcuts for isolating those targets. systemctl is-system-running reports running, degraded (some unit failed) or maintenance. systemd-analyze shows the boot time, systemd-analyze blame shows which units took longest, and systemd-analyze critical-chain shows what delayed the target. systemctl get-default on a remote host is a quick check that a server was not left booting into a desktop it does not need.

Practice

0 of 5 done

Do these on your own system. They get harder. Check each result, then tick it off.

  1. Warm-up

    Which target is the default?

    Show the default target, list the targets that are currently active, and list every target available on the system.

    Check your result

    systemctl get-default prints a target name such as multi-user.target or graphical.target. The other two commands list .target units.

    Hint

    systemctl list-units --type=target (active) and systemctl list-unit-files --type=target (available).

    Solution
    systemctl get-default
    systemctl list-units --type=target --no-pager
    systemctl list-unit-files --type=target --no-pager
  2. Practice

    Change what the machine boots into

    Make the system boot to graphical.target by default, verify the change, and then change it back to multi-user.target. State whether either change affected the running system.

    Check your result

    systemctl get-default prints graphical.target, then multi-user.target. The running session did not change: set-default only changes the default symlink.

    Hint

    systemctl set-default TARGET updates /etc/systemd/system/default.target. ls -l that path to see the link.

    Solution
    sudo systemctl set-default graphical.target
    systemctl get-default
    ls -l /etc/systemd/system/default.target
    sudo systemctl set-default multi-user.target
    systemctl get-default
  3. Practice

    Switch targets on a running system

    From a virtual-machine console (not over SSH, because isolating can drop network sessions), isolate rescue.target, observe what is running, and return to multi-user.target. Explain the difference between isolate and set-default.

    Check your result

    In rescue mode you get a root prompt after the root password and few services run. systemctl isolate multi-user.target brings the services back. isolate changes the current state; set-default changes the next boot.

    Hint

    systemctl isolate rescue.target asks for the root password. The list-dependencies command shows what a target pulls in.

    Solution
    systemctl list-dependencies multi-user.target --no-pager | head
    sudo systemctl isolate rescue.target
    # at the console: systemctl list-units --type=service --state=running | wc -l
    systemctl isolate multi-user.target
  4. Practice

    Warn users, schedule, cancel

    Schedule a reboot in 10 minutes with the message Maintenance reboot, check that it is pending, then cancel it. Then explain why reboot and systemctl reboot do the same thing.

    Check your result

    shutdown -r +10 with the message prints Shutdown scheduled for .... shutdown -c cancels it. ls -l $(which reboot) shows a link to systemctl.

    Hint

    shutdown -r +MINUTES message, shutdown -c. shutdown -h halts, -P powers off.

    Solution
    sudo shutdown -r +10 "Maintenance reboot"
    sudo shutdown -c
    ls -l $(which reboot)
  5. Challenge

    Turn a graphical server into a text-only one

    A server was installed with a desktop and boots into graphical.target. Without reinstalling anything, make it boot to the text console permanently. Prove it by checking the default target, then reboot and confirm with systemctl is-active graphical.target and who -r.

    Check your result

    After the reboot systemctl get-default is multi-user.target, systemctl is-active graphical.target prints inactive, and who -r shows run-level 3.

    Hint

    systemctl set-default multi-user.target, then reboot and verify. who -r reports the legacy run-level.

    Solution
    sudo systemctl set-default multi-user.target
    systemctl get-default
    sudo reboot
    # after the reboot
    systemctl get-default
    systemctl is-active graphical.target
    who -r