Beginner · Processes, services and logs · topic 16 of 57 · 25 min
Targets: the boot goal of the system
Explanation
Why targets?
At boot, systemd must know how far to go: start only the basics for a repair, start all network services for a server, or also start a graphical login for a desktop. A target is a named goal that pulls in a set of units. Booting means "reach the default target".
| Target | What you get | Typical use |
|---|---|---|
| graphical.target | Everything in multi-user + a graphical login | Desktops, workstations |
| multi-user.target | Text logins, network and all normal services | Servers (the usual default) |
| rescue.target | Single user, basic system, local disks mounted, root password needed | Repairs with most file systems available |
| emergency.target | Root file system mounted READ-ONLY, almost nothing else | Repairs when even rescue fails, e.g. a bad /etc/fstab |
Older RHEL used numbered run levels (3 for text, 5 for graphical). The names runlevel3.target and runlevel5.target still exist as aliases of multi-user and graphical, but use the new names.
Checking and changing the default
$ systemctl get-default
graphical.target
# 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.
# systemctl isolate multi-user.target # switch NOW (stops the desktop)
# systemctl isolate graphical.target # and back (only if a desktop is installed)Not every target can be isolated; only those meant to be a full system state (they have AllowIsolate=yes), such as multi-user, graphical, rescue and emergency.
Choosing a target for one boot
Sometimes you need a different target only once, for example because the server hangs during normal boot. At the GRUB boot menu, press e to edit the entry, go to the line that starts with linux, add systemd.unit=rescue.target (or emergency.target) at the end, and press Ctrl+X to boot. This change is not saved; the next boot is normal again. You will use this in the boot and recovery module.
linux ($root)/vmlinuz-5.14.0-427.13.1.el9_4.x86_64 root=/dev/mapper/rhel-root ro crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet systemd.unit=emergency.targetRescue versus emergency
- rescue.target mounts all local file systems from /etc/fstab and starts a few basic services. Use it to fix most problems, like a broken service or a forgotten setting.
- emergency.target mounts only the root file system, read-only. Use it when rescue cannot even start, typically because a line in /etc/fstab points at a missing disk. Remount root read-write first: mount -o remount,rw /.
- Both ask for the root password. Without it you need the password-reset method from the boot module.
Common mistakes
- Using isolate when the task says "make the system boot into text mode". isolate is temporary; set-default is permanent.
- Trying to edit files in emergency mode and getting "Read-only file system". Run mount -o remount,rw / first.
- Setting graphical.target on a server with no desktop packages. It still boots, but the target cannot be fully reached; use multi-user.target for servers.
Need help?
Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.
Try:
Watch the lesson
Targets: the boot goal of the system · 1/6
A target is a goal for the system: a group of units to start.
Prefer a video by a teacher? Find free videos on “systemd targets set-default multi-user graphical rescue emergency” on YouTube ↗
In real life: A training lab switches machines to text mode
A Linux training institute in Hyderabad uses old desktops as RHEL lab servers. The graphical desktop wastes 600 MB of RAM on each one. The trainer sets multi-user.target as the default on all 30 machines with one Ansible task, and each machine boots straight to a text login with more memory free for the students' labs.
# systemctl set-default multi-user.target
# reboot
...
web07 login:Practice (0/3 done)
Which command makes the server boot to text mode from now on?
A bad /etc/fstab line stops the boot even in rescue mode. Which target do you try next?
In your VM: check the default target, change it to the other one (graphical or multi-user), reboot to confirm, and set it back. Then boot once into rescue.target from the GRUB menu and come back out with a normal reboot.
Quick quiz
Read more (free)
Related help
Before this, learn
This topic builds on these. If something here feels new, open them first.
Related topics
- Logs: journalctl, rsyslog and a persistent journalProcesses, services and logs · same module
- Signals, kill and process priorityProcesses, services and logs · same module
- The boot process, step by stepBoot, recovery and containers
- GRUB2, kernel arguments and the default kernelBoot, recovery and containers
- SELinux: what it is and its modesSELinux and SSH
- Permanent mounts with /etc/fstab and UUIDsStorage: partitions, file systems and LVM
Questions people ask about this
Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.
Which target is the usual default on a RHEL server?
Answer: multi-user.target
Servers normally boot to multi-user.target.
In emergency mode, how is the root file system mounted?
Answer: Read-only
Root is read-only; use mount -o remount,rw / to change files.
Which old run level matches graphical.target?
Answer: 5
Run level 5 was graphical; 3 was multi-user text.
What does systemctl isolate do?
Answer: Switches the running system to that target now
isolate starts the target and stops units not needed by it.
What does systemctl mask do?Related
Answer: Makes the unit impossible to start until unmasked
It links the unit to /dev/null.
Which file shows the kernel arguments of the current boot?Related
Which command shows the kernel that boots by default?Related
Answer: grubby --default-kernel
uname -r shows the running kernel, which may differ.
Which policy does RHEL use by default?Related
Pass the quiz (60% or more) or mark this topic as done when you are ready.
Your progress is saved on this device only.
Next steps
- 2 more topics in “Processes, services and logs” before its exam: Logs: journalctl, rsyslog and a persistent journal, Tuning profiles with tuned, and time with chrony.
- Module 3 exam: Processes, services and logs · 14 questions · 25 min, without help. 6 topics of this module still to finish first.
- Then the next module, Software and networking. 57 topics left in the course before the final exam.