Systemd Targets and Their Functionality
Systemd and Targets
The kernel has started and systemd is now starting, initiating the default target of the system.
Definition of a Target
A systemd target is a group of unit files (units).
Some targets are isolatable, establishing the final state that the system starts in, while others are not isolatable.
Examples of Targets
printer.target: A target that groups all units relating to printing.
isolatable targets: These are critical for defining how the system starts.
emergency.target: This is the most minimal system state.
rescue.target: Offers more functionality than emergency.target.
multi-user.target: A functional system state without a graphical user interface (GUI).
graphical.target: A fully functional system state with a graphical user interface (GUI).
Enabling Units with systemctl
When a unit is enabled using
systemctl enable, the unit is associated with a specific target where it is added.Command to show all targets:
systemctl list-unit-files -t targetExample target to review: multi-user.target.
Command to view configuration:
systemctl cat multi-user.targetConfiguration includes:
Requires:
basic.target(ensures this target is included when starting multi-user.target).Allow isolatable: If true, indicates it can be used to start the system in a specific state.
Service Interaction with Targets
Example service: vsftpd.service.
Configuration can be viewed via:
systemctl cat vsftpd.serviceIn this service's install section, it states it is wanted by:
multi-user.target.
System behavior:
The service knows its target, but the target does not track which services it includes.
Upon disabling and then enabling the service, it creates a symbolic link at
etc/systemd/system/multi-user.target.wants.
Dependencies of a Target
Command to list dependencies:
systemctl list-dependencies multi-user.targetOutputs include the listed files and additional targets:
basic.target: Required for multi-user.target, ensuring it is always started alongside.
basic.target organizes boot process further by including other targets.
Booting with Specific Targets
At boot time, the target can be specified as a boot argument.
Pressing e on the default option allows you to modify boot parameters.
Use:
systemd.unit=multi-user.targetfollowed by pressing CTRL + X to boot into the multi-user target.
Troubleshooting targets such as emergency.target and rescue.target require a root password for access.
Entering Multi-User Target
Once logged in, the user is in text-only mode.
To switch back to graphical mode:
sudo systemctl start graphical.targetto resume the graphical user interface.