dotlinux blog

Working with systemd targets on RHEL7 Linux: A Beginner’s Cheatsheet

If you’re new to Red Hat Enterprise Linux (RHEL) 7, you’ve likely heard of systemd—the init system that replaced the traditional SysV init and Upstart in RHEL7. At the heart of systemd lies the concept of targets, which are logical groups of services and units that define the system’s state (e.g., “graphical mode,” “text-only mode,” or “emergency mode”).

Targets simplify managing system states by grouping related services (e.g., network, SSH, graphical interface) into reusable units. For beginners, understanding targets is critical for tasks like switching between CLI and GUI modes, troubleshooting boot issues, or configuring the system to start in a specific state.

This cheatsheet breaks down systemd targets in RHEL7, from basics to essential commands, with practical examples to help you get started.

2026-01

Table of Contents#

  1. Understanding systemd Targets
    • What Are Targets?
    • Targets vs. Runlevels (RHEL6 Comparison)
    • Targets vs. Services
  2. Common systemd Targets in RHEL7
  3. Essential systemd Target Commands
    • View Current Target
    • List All Targets
    • Set Default Target
    • Switch Targets Temporarily
    • Check Target Dependencies
    • View Target Unit Files
  4. Practical Example: Switch to Multi-User (CLI) Mode
  5. Troubleshooting Common Target Issues
  6. Conclusion
  7. References

1. Understanding systemd Targets#

What Are Targets?#

In systemd, a target is a unit file (.target) that defines a system state by grouping other units (services, sockets, mount points, etc.). Think of targets as “system profiles”—they determine which services start when the system boots or switches states.

For example:

  • graphical.target starts all services needed for a graphical desktop (e.g., gdm.service, network.service).
  • multi-user.target starts services for a text-only (CLI) environment (no GUI, but includes SSH, networking, etc.).

Targets vs. Runlevels (RHEL6 Comparison)#

If you’re familiar with RHEL6 or earlier, you might remember runlevels (e.g., runlevel 3 for CLI, runlevel 5 for GUI). Targets replace runlevels in systemd, but they’re more flexible:

  • Runlevels were numbered (0-6) and rigidly defined.
  • Targets have human-readable names (e.g., multi-user.target) and can be customized or extended.

Here’s how RHEL6 runlevels map to RHEL7 targets:

RHEL6 RunlevelPurposeRHEL7 Equivalent Target
0Halt the systempoweroff.target
1Single-user moderescue.target
2Multi-user (no network)multi-user.target (custom)
3Multi-user (CLI, network)multi-user.target
4UnusedN/A (custom targets possible)
5Graphical (GUI) modegraphical.target
6Rebootreboot.target

Targets vs. Services#

Targets are not services—they are groups of services. For example:

  • sshd.service is a service that starts the SSH daemon.
  • multi-user.target includes sshd.service (along with network.service, crond.service, etc.) to define a CLI environment.

2. Common systemd Targets in RHEL7#

Here are the most frequently used targets in RHEL7, with their purposes and runlevel equivalents:

Target NameDescriptionEquivalent RunlevelUse Case
multi-user.targetDefault CLI mode: starts network, SSH, cron, and other non-GUI services.Runlevel 3Server environments (no GUI needed).
graphical.targetGUI mode: includes multi-user.target + graphical services (e.g., gdm).Runlevel 5Desktop/laptop with a GUI.
rescue.targetSingle-user rescue mode: minimal system with root shell (no networking).Runlevel 1Troubleshooting (e.g., password recovery).
emergency.targetMinimal emergency mode: only root shell (no services/mounts).N/ACritical system failures (e.g., broken fstab).
poweroff.targetShuts down the system.Runlevel 0Graceful shutdown.
reboot.targetReboots the system.Runlevel 6Restart the system.
default.targetSymlink to the system’s default boot target (e.g., multi-user or graphical).N/ADefines the default boot state.

3. Essential systemd Target Commands#

All systemd target management is done with the systemctl command. Below are key commands to view, configure, and switch targets.

View Current Target#

To check which target the system is currently running:

systemctl get-default  

Example Output:

multi-user.target  # System boots to CLI by default  

List All Targets#

To list all targets (active and inactive), use:

systemctl list-targets  

Example Output (truncated):

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  
graphical.target       loaded active active Graphical Interface  # Active if GUI is running  
multi-user.target      loaded active active Multi-User System  
network.target         loaded active active Network  
...  

Set Default Target#

The default target determines the system’s state at boot. To set a new default (persistent across reboots):

sudo systemctl set-default <target-name>  

Examples:

  • Set default to CLI (multi-user):
    sudo systemctl set-default multi-user.target  
  • Set default to GUI (graphical):
    sudo systemctl set-default graphical.target  

Switch Targets Temporarily#

To switch to a target immediately (without rebooting), use isolate (temporarily activates the target and stops conflicting units):

sudo systemctl isolate <target-name>  

Examples:

  • Switch to GUI mode temporarily:
    sudo systemctl isolate graphical.target  
  • Switch to rescue mode (single-user):
    sudo systemctl isolate rescue.target  

Check Target Dependencies#

To see which services/targets a target depends on (e.g., what graphical.target includes):

systemctl list-dependencies <target-name>  

Example:

systemctl list-dependencies graphical.target  

Output (truncated):

graphical.target  
├─accounts-daemon.service  
├─gdm.service               # Gnome Display Manager (GUI)  
├─rtkit-daemon.service  
├─systemd-update-utmp-runlevel.service  
└─multi-user.target         # Includes all services from multi-user  
  ├─auditd.service  
  ├─crond.service  
  ├─network.service  
  └─sshd.service            # SSH daemon  

View Target Unit File#

To inspect the raw configuration of a target (e.g., multi-user.target):

systemctl cat <target-name>  

Example:

systemctl cat multi-user.target  

Output:

# /usr/lib/systemd/system/multi-user.target  
[Unit]  
Description=Multi-User System  
Documentation=man:systemd.special(7)  
Requires=basic.target  
Conflicts=rescue.service rescue.target  
After=basic.target rescue.service rescue.target  
AllowIsolate=yes  

4. Practical Example: Switch to Multi-User (CLI) Mode#

Let’s walk through a common scenario: A RHEL7 desktop is booting to GUI (graphical.target), but you want to switch to CLI (multi-user.target) as the default.

Step 1: Check Current Default Target#

systemctl get-default  

Output:

graphical.target  # Currently boots to GUI  

Step 2: Switch Temporarily to CLI#

To test CLI mode without changing the default:

sudo systemctl isolate multi-user.target  

The GUI will close, and you’ll land at a text-based login prompt.

Step 3: Set CLI as Default (Persistent)#

To make CLI the default boot target:

sudo systemctl set-default multi-user.target  

Output:

Removed symlink /etc/systemd/system/default.target.  
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target.  

Step 4: Verify the Change#

Reboot to confirm the system now boots to CLI:

sudo reboot  

After reboot, you’ll see a text-based login prompt (no GUI).

5. Troubleshooting Common Target Issues#

Default Target Not Persisting#

If set-default doesn’t save your default target, check the default.target symlink:

ls -l /etc/systemd/system/default.target  

Expected Output:

lrwxrwxrwx. 1 root root 37 Jun 10 14:22 /etc/systemd/system/default.target -> /usr/lib/systemd/system/multi-user.target  

If the symlink is missing/corrupted, recreate it manually:

sudo ln -sf /usr/lib/systemd/system/multi-user.target /etc/systemd/system/default.target  

Target Fails to Activate#

If switching to a target (e.g., rescue.target) fails, check the system logs with journalctl:

journalctl -u <target-name>  # e.g., journalctl -u rescue.target  

Look for errors like “Failed to start Rescue Mode” to diagnose issues (e.g., missing dependencies).

Stuck in Emergency Mode#

If the system boots to emergency.target, it’s likely due to critical errors (e.g., invalid /etc/fstab entries). To fix:

  1. Enter the root password when prompted.
  2. Run journalctl -xe to check logs for failures.
  3. Fix the issue (e.g., edit /etc/fstab with vi /etc/fstab).
  4. Reboot: systemctl reboot.

6. Conclusion#

systemd targets are the backbone of system state management in RHEL7. By mastering targets, you can control your system’s boot behavior, switch between CLI/GUI modes, and troubleshoot boot issues with confidence.

Start with the basics: Use systemctl get-default to check your current target, set-default to configure boot behavior, and isolate to switch states temporarily. Refer to the common targets table for quick reference, and don’t hesitate to inspect dependencies with list-dependencies.

7. References#