Skip to content

Click on each book below to review & buy on Amazon.

As an Amazon Associate, I earn from qualifying purchases.


RHCSA - Deploy, Configure, & Maintain Systems: Configure Systems to Boot Into a Specific Target Automatically

Ensure that for production systems you always communicate with any stakeholders before booting into different targets.

Targets

In systemd-based Linux distributions, targets represent specific system states or sets of services that can be activated or deactivated to manage the system's behavior during boot and runtime.

Below is a table of the typical targets you can boot into:

Target Description
default.target The default target that is reached after the system has finished booting. It typically starts the system in the default runlevel.
emergency.target This target is used in emergency situations where the system is in an unusable state. It provides a minimal environment for recovery tasks.
graphical.target This target is used to start the system with a graphical user interface (GUI) environment, such as X11 or Wayland.
multi-user.target This target is used to start the system with a multi-user environment, without a GUI. It provides a text-based login prompt.
rescue.target This target is similar to the emergency.target, but it provides a more complete environment for performing system recovery tasks.

The default.target is used during a normal boot of the system.

Determine the Default Target

The default.target is determined by a link that points to the actual target that should be booted into.

Display where the default.target links to:

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

If unchanged since since setting up your system for this course, the ls output should show similar to the following:

lrwxrwxrwx. 1 root root 40 Jun 22 07:50 /etc/systemd/system/default.target -> /usr/lib/systemd/system/graphical.target

There is an easier way to find out what the default.target is though, which is by using the systemctl get-default command.

Determine the systems default.target:

systemctl get-default

List Available Targets to Boot into

You can list available targets on your system using the systemctl list-units --type=target command, however this will list all targets and not just the ones that can be isolated. The AllowIsolate=yes setting in the targets unit file determines if the target can be isolated or booted into.

List all targets:

systemctl list-units --type=target

This command will show a list of targets along with their current state.

Locate all targets that can be isolated:

grep -E 'AllowIsolate=(yes|'yes'|"yes")' /usr/lib/systemd/system/*.target

This command will search all target files in the /usr/lib/systemd/system directory that have AllowIsolate set to yes.

Changing the Default Target

To change the default.target to point to the preferred environment to start in during a normal boot, you use the systemctl set-default command.

Change the default.target to point to the multi-user.target:

If your default was already the multi-user.target then you can use the rescue.target to practice instead.

If you do use the rescue.target, ensure you know the root password, otherwise you will have to follow Interrupt the Boot Process in Order to Gain Access to a System in order to login.

sudo systemctl set-default multi-user.target

The output of this command will show the symlink being updated to point to the chosen target:

Removed "/etc/systemd/system/default.target".
Created symlink /etc/systemd/system/default.target -> /usr/lib/systemd/system/multi-user.target.

Reboot into Default Target

You will want to ensure that following a reboot, the system boots into your chosen target, especially if this was one of the tasks set on your exam.

Reboot system and check you are in the correct target:

sudo reboot

This command will initiate a system reboot, and upon startup, the system will automatically boot into the default.target.

Revert the Default Target Change

To leave your system booting to your normal target you use, run the systemctl set-default command again and reboot.

Revert to previously used target:

Replace graphical with your usual target, for example multi-user if that was what yours was before:

sudo systemctl set-default graphical.target
sudo reboot


Support DTV Linux

Click on each book below to review & buy on Amazon. As an Amazon Associate, I earn from qualifying purchases.

NordVPN ®: Elevate your online privacy and security. Grab our Special Offer to safeguard your data on public Wi-Fi and secure your devices. I may earn a commission on purchases made through this link.