Service management
|
|
Checking status
|
|
System state overview
|
|
To see every available units in the system paths (including those that systemd
has not attempted to load):
|
|
The state:
enabled
disabled
static
: means that the unit files does not contain aninstall
section, which is used to enable a unit.masked
:
Unit management
Show a unit file
To display the unit file that systemd
has loaded into the system:
|
|
Display dependencies
To see a unit’s dependency tree:
|
|
Using shortcuts for important events
Put the system into rescue (single-user) mode:
|
|
To halt the system:
|
|
To initiate a full shutdown:
|
|
For restart:
|
|
Listing available targets
A list of the available targets:
|
|
Unlike runlevels, multiple targets can be active at one time. An active target indicates that systemd
has attempted to start all of the units tied to the target and has not tried to tear them down again.
To see all of the active targets:
|
|
Default target
To find the default target for system:
|
|
To set different default target:
|
|
Editing unit files
Edit unit file:
|
|
This will be a blank file that can be used to override or add directives to the unit definition. A directory will be created within the /etc/systemd/system
directory which contains the name of the unit with .d appended. For instance, for the nginx.service
, a directory called nginx.service.d
will be created.
Within this directory, a snippet will be created called override.conf. When the unit is loaded, systemd
will, in memory, merge the override snippet with the full unit file. The snippet’s directives will take precedence over those found in the original unit file.
To edit the full unit file instead of creating a snippet:
|
|
After editing, deleting file or directory:
|
|
Check unit properties
To see the low-level properties of a unit:
|
|
To see the conflicts:
|
|
Masking or unmasking units
|
|
To mark a unit as completely unstartable, automatically or manually, by linking it to /dev/null, we can mask the unit.
To unmask:
|
|