Inspect default target with systemctl get-default
As mentioned earlier, modern Linux distributions often use systemd
instead of the traditional SysVinit system. systemd
uses "targets" which are similar in concept to runlevels but offer more flexibility.
A target is a group of systemd
units (like services, mount points, sockets, etc.) that the system should start or stop to reach a desired state. The default target is the state the system boots into.
We can use the systemctl
command to interact with systemd
. The get-default
subcommand shows the default target.
Note: Due to the nature of the LabEx environment running in a Docker container, the systemctl
command might behave differently or show limited information compared to a full operating system installation. However, we can still use it to understand the concept of default targets.
In your terminal, type the following command and press Enter:
systemctl get-default
You should see output similar to this:
graphical.target
This output indicates that the default target for this system is graphical.target
. This target typically includes all the services needed for a multi-user system with a graphical desktop environment, which aligns with the runlevel 5
we saw earlier.
Other common targets include:
multi-user.target
: Similar to runlevel 3, a multi-user system without a graphical interface.
rescue.target
: A single-user mode for system recovery.
reboot.target
: Used for rebooting the system.
poweroff.target
: Used for shutting down the system.
While you might not be able to change the default target in this LabEx environment, understanding how to check it with systemctl get-default
is a fundamental skill for managing systemd
-based systems.
You have now learned three different ways to check the system's operating state or its default boot state: runlevel
, who -r
, and systemctl get-default
.
Click Continue to complete this lab.