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-defaultsystemctl set-defaultsystemctl isolatesystemctl list-dependenciesrebootpoweroffshutdownsystemctl rescuewho
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.
| Target | Meaning | Old run level |
|---|---|---|
poweroff.target | Shut the machine down | 0 |
rescue.target | Single-user mode: base system and file systems mounted, root shell, no network | 1 |
emergency.target | Minimal: root file system read-only, almost nothing else | n/a |
multi-user.target | Full text-mode system with networking | 3 |
graphical.target | multi-user plus a graphical login | 5 |
reboot.target | Reboot | 6 |
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:
| Command | Changes | Takes effect |
|---|---|---|
systemctl set-default TARGET | The default for future boots | Next boot |
systemctl isolate TARGET | The current state, stopping what the target does not include | Immediately |
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.
- 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-defaultprints a target name such asmulti-user.targetorgraphical.target. The other two commands list.targetunits.Hint
systemctl list-units --type=target(active) andsystemctl 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 - 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-defaultprintsgraphical.target, thenmulti-user.target. The running session did not change:set-defaultonly changes the default symlink.Hint
systemctl set-default TARGETupdates/etc/systemd/system/default.target.ls -lthat 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 - 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 tomulti-user.target. Explain the difference betweenisolateandset-default.Check your result
In rescue mode you get a root prompt after the root password and few services run.
systemctl isolate multi-user.targetbrings the services back.isolatechanges the current state;set-defaultchanges the next boot.Hint
systemctl isolate rescue.targetasks for the root password. Thelist-dependenciescommand 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 - 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 whyrebootandsystemctl rebootdo the same thing.Check your result
shutdown -r +10with the message printsShutdown scheduled for ....shutdown -ccancels it.ls -l $(which reboot)shows a link tosystemctl.Hint
shutdown -r +MINUTES message,shutdown -c.shutdown -hhalts,-Ppowers off.Solution
sudo shutdown -r +10 "Maintenance reboot" sudo shutdown -c ls -l $(which reboot) - 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 withsystemctl is-active graphical.targetandwho -r.Check your result
After the reboot
systemctl get-defaultismulti-user.target,systemctl is-active graphical.targetprintsinactive, andwho -rshowsrun-level 3.Hint
systemctl set-default multi-user.target, thenrebootand verify.who -rreports 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