Course contentsShow
← Linux
Lesson 599 of 1,8196. Systemd Internals and Unit OrchestrationFree lesson

Manipulating the Default Target

Switch the boot target and understand how default.target is symlinked.

In this lesson, you will learn how to configure your system’s boot state by manipulating the default.target symlink.

The Role of default.target

In systemd, the "target" concept acts as a synchronization point for bootup. While your system has many targets (like multi-user.target for command-line only, or graphical.target for desktop environments), the system needs to know which one to reach at the end of the initialization chain. This is governed by default.target.

If you look inside /etc/systemd/system/, you will see a file named default.target. This is not a standard configuration file; it is a symbolic link pointing to the actual unit file you want your system to prioritize. By changing where this link points, you dictate the entire "mode" in which your OS boots.

Changing the Default Target

Instead of manually creating symlinks, systemd provides a friendly command to handle this process for you:

# Set the system to boot into the command-line interface
sudo systemctl set-default multi-user.target

# Set the system to boot into the desktop environment
sudo systemctl set-default graphical.target

When you run these commands, systemd removes the existing /etc/systemd/system/default.target symlink and recreates it to point to the target you specified. You can verify this manually at any time by running:

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

You will see output similar to: lrwxrwxrwx 1 root root ... /etc/systemd/system/default.target -> /usr/lib/systemd/system/multi-user.target

This mechanism is the "final word" for PID 1 when it finishes loading the essential services. By changing this link, you aren't just changing a setting; you are redefining the entire dependency tree that the system resolves during its boot sequence. If you ever need to troubleshoot a system that fails to boot into a graphical environment, changing the default.target back to multi-user.target is often the first step in restoring system stability.

Key Takeaway: The default.target is simply a symbolic link that tells the system which initialization milestone to finalize during boot, and systemctl set-default is the safe, standard way to update that link.