Skip to content

Beginner · Processes, services and logs · topic 16 of 57 · 25 min

Targets: the boot goal of the system

Explanation

A target is a group of units that brings the system to a state, such as multi-user.target (text mode, network, services) or graphical.target (plus a desktop). systemctl get-default shows the boot target, set-default changes it, and isolate switches now. rescue.target and emergency.target are for repairs.

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".

TargetWhat you getTypical use
graphical.targetEverything in multi-user + a graphical loginDesktops, workstations
multi-user.targetText logins, network and all normal servicesServers (the usual default)
rescue.targetSingle user, basic system, local disks mounted, root password neededRepairs with most file systems available
emergency.targetRoot file system mounted READ-ONLY, almost nothing elseRepairs 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

bash
$ 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)
set-default changes the next boot; isolate changes the running system.

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.

bash
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.target
The kernel line in the GRUB editor, with systemd.unit=emergency.target added at the end.

Rescue 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

target = goal

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.

bash
# systemctl set-default multi-user.target
# reboot
...
web07 login:

Practice (0/3 done)

Task 1 · Question

Which command makes the server boot to text mode from now on?

Task 2 · Question

A bad /etc/fstab line stops the boot even in rescue mode. Which target do you try next?

Task 3 · Practice

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

Question 1

1.Which target is the usual default on a RHEL server?

Question 2

2.In emergency mode, how is the root file system mounted?

Question 3

3.Which old run level matches graphical.target?

Question 4

4.What does systemctl isolate do?

Read more (free)

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.

From systemd services and systemctl

Which file shows the kernel arguments of the current boot?Related

Answer: /proc/cmdline

/proc/cmdline.

From The boot process, step by step

Which command shows the kernel that boots by default?Related

Answer: grubby --default-kernel

uname -r shows the running kernel, which may differ.

From GRUB2, kernel arguments and the default kernel

Which policy does RHEL use by default?Related

Answer: targeted

targeted confines services.

From SELinux: what it is and its modes

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

  1. 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.
  2. Module 3 exam: Processes, services and logs · 14 questions · 25 min, without help. 6 topics of this module still to finish first.
  3. Then the next module, Software and networking. 57 topics left in the course before the final exam.

← Previous: systemd services and systemctl