Units
A unit is an entity that allows to specify dependencies that are needed for
booting up Linux.
Type
A unit has one of the following 11 types
service | |
mount point | |
device | |
socket | |
automount point | |
swap file | |
partition | |
target | Useful to group units and/or provide well-known synchronization points during boot up. These seem to be the systemd equivalent of the runlevels of System-V. |
timer | |
resource management slice | |
group of externally created processes | |
Show units of a given type:
systemctl --type=service
systemctl --type=service,mount
Available unit types can be shown with
systemctl --type=help
Unit state
A unit is either active, inactive, activating, deactivating or failed.
Each state has a set of substates.
Units are started and stopped on the command line with
systemctl start …
systemctl stop …
Check if a unit is activated or is failed::
systemctl is-activated systemd-networkd
systemctl is-failed systemd-networkd
Enabled/disabled units
A unit is either enabled or disabled.
An enabled unit becomes subject to automatic starting when a certain event occurs, such as booting the system or a specific kind of hardware is plugged in.
Thus, a unit can be active and disabled, inacative and enabled, active and enabled and inactive and disabled.
A unit is enabled or disabled on the command line with
systemctl enable
and
systemctl disable
sudo systemctl disable displaylink.service
Removed "/etc/systemd/system/multi-user.target.wants/displaylink-driver.service".
Check if a unit is enabled:
systemctl is-enabled systemd-networkd
How a unit is enabled is specified in the [Install]
section of the unit file.
Unit names - Configuration files
Units are configured in unit configuration files («unit files»).
The name of the unit corresponds to that of the configuration file.
Unit configuration files are searched for in
The absolute path of a unit file (here: systemd-networkd.service
, .service
can be omitted) can be printed on the command line with
systemctl show systemd-networkd -p FragmentPath
A unit file might contain an [Install]
section which specifies what happens when a unit is enabled.
Listing units per type:
The following command lists all loaded and active target units:
$ systemctl list-units --type=target
With --all
, inactive target units are shown as well.
$ systemctl list-units --type=target -all
See also
man systemd.unit