Add a service


systemctl – Control the systemd system and service manager

list-timers [PATTERN...]List timer units currently in memory, ordered by the time they elapse next.
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.

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*

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.
-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.
-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 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



systemd-resolve – Resolve domain names, IPV4 and IPv6 addresses, DNS resource records, and services

systemd-resolve --status
systemd-resolve 2603:400a:ffff:bb8::801f:3e

systemd-resolve --flush-caches
systemd-resolve --statistics

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


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


Important folders



man systemd.unit