Add a service


systemctl – Control the systemd system and service manager

list-units [PATTERN…]List units that systemd currently has in memory.
list-sockets [PATTERN…]List socket units currently in memory, ordered by listening address.
list-timers [PATTERN...]List timer units currently in memory, ordered by the time they elapse next.
list-jobs [PATTERN…]List jobs that are in progress.
list-dependencies [UNIT…]Shows units required and wanted by the specified units.
enable UNIT..., enable PATH...Enable one or more units or unit instances. This will create a set of symlinks, as encoded in the “[Install]” sections of the indicated unit files. After the symlinks have been created, the system manager configuration is reloaded (in a way equivalent to daemon-reload), in order to ensure the changes are taken into account immediately.
disable UNIT...Disables one or more units. (won’t start automatically)
mask UNIT...Mask one or more units, as specified on the command line. This will link these unit files to /dev/null, making it impossible to start them. This is a stronger version of disable, since it prohibits all kinds of activation of the unit, including enablement and manual activation. Use this option with care.
suspendSuspend the system. This will trigger activation of the special target unit This command is asynchronous, and will return after the suspend operation is successfully enqueued. It will not wait for the suspend/resume cycle to complete.

A unit file is a plain text ini-style file that encodes information about a service, a socket, a device, a mount point, an automount point, a swap file or partition, a start-up target, a watched file system path, a timer controlled and supervised by systemd(1), a resource management slice or a group of externally created processes. See systemd.syntax(7) for a general description of the syntax.

Usual tasks

systemctl status postfix
systemctl reload-or-restart postfix
Get a list of enabled services
systemctl list-unit-files | grep enabled
Disable a unit (service/timer)

(won’t autostart, but it can still be run manually)

systemctl disable <service>
Get systemd version
# systemctl --version
systemd 239
List timers
systemctl list-timers --all
systemctl list-timers *apt*
List jobs
systemctl list-jobs
List units in failed state
systemctl --state=failed
systemctl --failed
sudo systemctl daemon-reload
sudo systemctl reset-failed
Suspend the system
systemctl suspend

journalctl – Query the systemd journal

journalctl pipes its output to the less command, which shows your logs one page at a time in your terminal.

-f, –followShow only the most recent journal entries, and continuously print new entries as they are appended to the journal.
-e, –pager-endImmediately jump to the end of the journal inside the implied pager tool.
-r, –reverseReverse output so that the newest entries are displayed first.
-q, –quietSuppresses all informational messages (i.e. “– Journal begins at …”, “– Reboot –“), any warning messages regarding inaccessible system journals when run as a normal user.
-b [[ID][±offset]|all], –boot[=[ID][±offset]|all]Show messages from a specific boot. This will add a match for “_BOOT_ID=”.
The argument may be empty, in which case logs for the current boot will be shown.
-u,–unit=UNIT|PATTERNShow messages for the specified systemd unit UNIT (such as a service unit), or for any of the units matched by PATTERN.
This parameter can be specified multiple times.
–user-unit=Show messages for the specified user session unit.
-p, –priority=Filter output by message priorities or priority ranges.
“emerg” (0), “alert” (1), “crit” (2), “err” (3), “warning” (4), “notice” (5), “info” (6), “debug” (7)
-S, –since=,
-U, –until=
Start showing entries on or newer than the specified date, or on or older than the specified date, respectively.
–disk-usageShows the current disk usage of all journal files. This shows the sum of the disk usage of all archived and active journal files.
–rotateAsks the journal daemon to rotate journal files.
Removes the oldest archived journal files until the disk space they use falls below the specified size/older than/specified number of separate journal files
-x, –catalogAugment 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.

Show journal and follow

journalctl -f

Show errors

journalctl -p 3 -xb
journalctl -p err -xb

Show journal and follow, showing only a certain unit

journalctl -f -u NetworkManager
journalctl -f -u pvedaemon

Show today’s logs associated to a certain unit

journalctl -S today -u sanoid.service
journalctl -f -S today -u sanoid.service -u syncoid.service

Immediately jump to the end of the journal inside the implied pager tool

journalctl -e 

Get the log at a specific time

journalctl --since "2020-08-22 23:15:00" --until "2020-08-22 23:45:00"

List boots

journalctl --list-boots

Show all messages from this boot (and last boot)

journalctl -b
journalctl -b -1


Clear logs

networkctl list
networkctl status -a

timedatectl – Control the system time and date

timedatectl may be used to query and change the system clock and its settings.

$ timedatectl
               Local time: Tue 2021-10-12 12:06:50 CEST
           Universal time: Tue 2021-10-12 10:06:50 UTC 
                 RTC time: Tue 2021-10-12 10:06:50     
                Time zone: Europe/Berlin (CEST, +0200) 
System clock synchronized: yes                         
              NTP service: active                      
          RTC in local TZ: no
timedatectl list-timezones
timedatectl set-timezone Europe/Berlin
$ timedatectl status
$ timedatectl timesync-status
$ timedatectl show-timesync --all
$ vi /etc/systemd/timesyncd.conf
$ systemctl restart systemd-timesyncd.service


resolvectl, resolvconf – Resolve domain names, IPV4 and IPv6 addresses, DNS resource records, and service

In systemd 239 systemd-resolve has been renamed to resolvectl

query HOSTNAME|ADDRESS…Resolve domain names, as well as IPv4 and IPv6 addresses.
openpgp EMAIL@DOMAIN…Query PGP keys stored as OPENPGPKEY resource records, see RFC 7929[3]. Specified e-mail addresses are converted to the corresponding DNS domain name, and any OPENPGPKEY keys are printed.
status [LINK…]Shows the global and per-link DNS settings currently in effect.
statisticsShows general resolver statistics, including information whether DNSSEC is enabled and available, as well as resolution and validation statistics.
flush-cachesFlushes all DNS resource record caches the service maintains locally.
dnsGet/set per-interface DNS configuration. These commands may be used to configure various DNS settings for network interfaces.
resolvectl status

Resolve domain or IP

$ resolvectl query              -- link: enp5s0

-- Information acquired via protocol DNS in 28.6ms.
-- Data is authenticated: no; Data was acquired via local or encrypted transport: no
-- Data from: cache network
$ resolvectl query         -- link: enp5s0

-- Information acquired via protocol DNS in 104.8ms.
-- Data is authenticated: no; Data was acquired via local or encrypted transport: no
-- Data from: network
$ resolvectl query 2603:400a:ffff:bb8::801f:3e
2603:400a:ffff:bb8::801f:3e: -- link: enp5s0

-- Information acquired via protocol DNS in 750.5ms.
-- Data is authenticated: no; Data was acquired via local or encrypted transport: no
-- Data from: network
To query DNS connected behind an interface

(for instance tun0 in the case of VPN):

resolvectl -i tun0 query server_behind_VPN

Flush cache

resolvectl flush-caches


resolvectl statistics


coredumpctl – Retrieve and process saved core dumps and metadata

listList core dumps captured in the journal matching specified characteristics.
infoShow detailed information about the last core dump or core dumps matching specified characteristics captured in the journal.
coredumpctl list

systemd-analyze – Analyze and debug system manager

As bootchart as been merged in systemd, it is possible to plot the boot sequence to discover what is taking time.

systemd-analyze plot > systemd-analyze-ares.svg
ssh systemd-analyze plot > systemd-analyze-openmediavault.svg


systemctl list-timers
systemctl status sanoid.timer
sudo systemctl enable sanoid.timer
sudo systemctl start sanoid.timer


Important folders



man systemd.unit