This document is a WORK IN PROGRESS.
This is just a quick personal cheat sheet: treat its contents with caution!
SystemD¶
SystemD is a suite of basic building blocks for a Linux system. It provides a system and service manager that runs as PID 1 and starts the rest of the system.
Reference(s)
Table of contents¶
TODO
Services¶
Basic services control¶
-
Start the
service_name
service: -
Stop the
service_name
service: -
Restart the
service_name
service: -
Reload
service_name
configuration without stopping theservice_name
service: -
Check the
service_name
service status: -
Enable the
service_name
service on system boot: -
Disable the
service_name
service on system boot: -
Check if the
service_name
service is enable or disable on system boot:
Inspect services¶
- Check if any SystemD services have entered in a failed state:
Override services¶
Let's you want the ntpd
service to automatically restart if a failure happens. You could
"manually" edit the associated .service
file (/usr/lib/systemd/system/ntpd.service
), but this
file could be overritten after a system update or package install. This is where the systemctl
edit
command is interresting, it will create an associated override.conf
file that will always
apply:
-
Edit the override file (e.g. of
ntpd.service
, located in/etc/systemd/system/ntpd.service.d/override.conf
and not in/usr/lib/systemd/system/ntpd.service
) : -
Check the syntax e.g. of
/usr/lib/systemd/system/ntpd.service
and/etc/systemd/system/ntpd.service.d/override.conf
: -
Print the full ntpd service (
ntpd.service
andntpd.servce.d/override.conf
) :$ systemctl cat ntpd.service > # /usr/lib/systemd/system/ntpd.service > [Unit] > Description=Network Time Service > After=syslog.target ntpdate.service sntp.service > > [Service] > Type=forking > EnvironmentFile=-/etc/sysconfig/ntpd > ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS > PrivateTmp=true > > [Install] > WantedBy=multi-user.target > > # /etc/systemd/system/ntpd.service.d/override.conf > [Service] > Restart=on-failure
Analyze services¶
Reference(s)
- Create an SVG graphic detailing which system services have been started at what time, highlighting the time they spent on initialization:
Run levels¶
TODO
Tips and tricks¶
-
Start system in a non-graphical mode:
-
Check SystemD
journal
for a service:-x, --catalog
: Augment log lines with explanation texts from the message catalog. This will add explanatory help texts to log messages in the output where this is available. These short help texts will explain the context of an error or log event, possible solutions, as well as pointers to support forums, developer documentation, and any other relevant manuals.-e, --pager-end
Immediately jump to the end of the journal inside the implied pager tool.-u, --unit=UNIT|PATTERN
Show messages for the specified systemd unit UNIT (such as a service unit), or for any of the units matched by PATTERN.
If this cheat sheet has been useful to you, then please consider leaving a star here.