Systemd
Contents
About
Migration from /lib to /usr/lib
With the migration of SystemD from /lib to /usr/lib some links may be broken.
1 find /etc/systemd -xtype l -exec ls -l --color=always {} \;
These broken links can be regenerated by disabling and enabling them. Here's a naive fix.
Analyse targets
These commands may reveal some configuration problems like boot-loops
Some common commands
List enabled/disabled units
This is quite useful
1 systemctl list-unit-files
Just a note for SystemV
sysv-rc-conf
update-rc.d
Enable/disable units
View unit-definitions
1 systemctl cat smbd.service
Journal
- Checking the logs is a essential part a sysadmins every-day work
- man-pages
1 journalctl -xn40
List failed units
1 systemctl --failed
systemd-resolved
Network Name Resolution manager
systemd-resolved is a system service that provides network name resolution to local applications. It implements a caching and validating DNS/DNSSEC stub resolver, as well as an LLMNR and MulticastDNS resolver and responder.
3 interfaces:
- native, fully-featured API on the bus
- The glibc getaddrinfo(3) API as defined by RFC3493[1]
DNS stub resolver listening on 127.0.0.53 on the loopback interface
Man pages
systemd-resolved is enabled, you may use.
1 resolvectl status
/etc/systemd/resolved.conf
1 # This file is part of systemd.
2 #
3 # systemd is free software; you can redistribute it and/or modify it
4 # under the terms of the GNU Lesser General Public License as published by
5 # the Free Software Foundation; either version 2.1 of the License, or
6 # (at your option) any later version.
7 #
8 # Entries in this file show the compile time defaults.
9 # You can change settings by editing this file.
10 # Defaults can be restored by simply deleting this file.
11 #
12 # See resolved.conf(5) for details
13
14 [Resolve]
15 #DNS=
16 #FallbackDNS=
17 #Domains=
18 #LLMNR=yes
19 #MulticastDNS=yes
20 #DNSSEC=allow-downgrade
21 #DNSOverTLS=no
22 #Cache=yes
23 #DNSStubListener=yes
24 #ReadEtcHosts=yes
modes
systemd-resolved has for modes for /etc/hosts, which is detected automatically.
Please see:
man -P "less -p '/ETC/RESOLV.CONF'" systemd-resolved
stub, static, uplink, foreign
stub (recommended)
/etc/resolv.conf is a link on /run/systemd/resolv/stub-resolv.conf
static
/usr/lib/systemd/resolv.conf exists and /etc/resolv.conf may be a link on this file for compatibility. There is no "search-domains".
uplink
/etc/resolv.conf is a link on /run/systemd/resolve/resolv.conf
foreign
/etc/resolv.conf is a file, which is managed by other packages or is simply static.
To change the behavior to the recommended behavior stub you may:
A reboot is not necessary.
bootcharts
systemd-analyse
Create a bootchart /root/systemd_boot.sh
1 #!/bin/bash
2 DATE="$(date +%F_%T)"
3 GRAPH_PATH="/run/log"
4 GRAPH_FILE="systemd-analyse_plot_${DATE}.svg"
5 GRAPH="$GRAPH_PATH/$GRAPH_FILE"
6 GRAPH_LATEST="$GRAPH_PATH/systemd-analyse_plot_latest.svg"
7 systemd-analyze plot > "$GRAPH"
8 [[ -f "$GRAPH_LATEST" ]] && unlink "$GRAPH_LATEST"
9 ln -s "$GRAPH" "$GRAPH_LATEST"
10 cat <<-EOF
11 file://$GRAPH_LATEST
12 file://$GRAPH
13 EOF
file:///run/log/systemd-analyse_plot_latest.svg
It makes sense to open it with a browser to be able to search the graph with CTRL+F.
systemd-bootchart
Install
1 aptitude install systemd-bootchart
Reboot
ll -a /run/log/
tmpfiles.d
man tmpfiles.d
/etc/tmpfiles.d/pdf.conf