Systemd

systemctl list-dependencies
systemctl list-dependencies libvirtd --all
systemctl status [___.service]
systemctl | grep ssh
systemctl --failed
systemctl daemon-reload # scanning for new or changed units
systemctl enable unit # start on boot
systemctl mask unit # make it impossible to start
sudo systemd-analyze plot > /tmp/systemd-startup.svg
fbi /tmp/systemd-startup.svg

  • .service: default
  • [email protected]: instances of a template unit, actually '[email protected]
  • .mount, E.g.: /home is equivalent to home.mount
  • .device, E.g.: /dev/sda2 is equivalent to dev-sda2.device
  • .socket
  • .slice
# when running in system mode (--system)
ls -l /run/systemd/system # Runtime units
ls -l /usr/lib/systemd/system # Units of installed packages
ls -l /etc/systemd/system # Local configuration, by SA

SysV Runlevel systemd Target Notes
0 runlevel0.target, poweroff.target Halt the system.
1, s, single runlevel1.target, rescue.target Single user mode.
2, 4 runlevel2.target, runlevel4.target, multi-user.target User-defined/Site-specific runlevels. By default, identical to 3.
3 runlevel3.target, multi-user.target usually login via multiple consoles or network.
5 runlevel5.target, graphical.target Multi-user, graphical.
6 runlevel6.target, reboot.target Reboot
emergency emergency.target Emergency shell
systemctl isolate multi-user.target # switch to target
systemctl get-default # current target
systemctl set-default multi-user.target

http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F /etc/systemd/system/foobar.service.d/*.conf # override settings
systemctl cat unit
systemctl edit --full ssh
systemctl edit --force new
[Unit]
Description=new
[Service]
ExecStart=/usr/sbin/new-daemon
[Install]
WantedBy=multi-user.target

cp -pv foo.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable foo
systemctl start foo
systemctl status foo

/etc/systemd/system.conf
LogLevel=debug
LogTarget=syslog-or-kmsg

# http://man7.org/linux/man-pages/man5/journald.conf.5.html
sudo mkdir -p /var/log/journal # persistent storage
journalctl -u unit
SYSTEMD_LESS="FRXMK" journalctl -u docker -n 100
-S, --since=, -U, --until=

systemctl status systemd-networkd.service
systemctl restart systemd-networkd.service
# networkctl list
IDX LINK TYPE OPERATIONAL SETUP
1 lo loopback carrier unmanaged
2 enp3s0 ether no-carrier unmanaged
3 eno1 ether degraded unmanaged
4 eno2 ether degraded configured
7 docker0 ether routable unmanaged
9 vethec09cbe ether degraded unmanaged
11 veth5185e04 ether degraded unmanaged
12 zt0 ether routable unmanaged
13 br0 ether routable configured
14 macvtap0 ether degraded unmanaged
15 vnet0 ether degraded unmanaged
16 br8 ether off unmanaged
18 macvtap1 ether degraded unmanaged
19 vnet1 ether degraded unmanaged

ls /etc/systemd/network # local administration network directory
ls /usr/lib/systemd/network # system network directory
ls /run/systemd/network # volatile runtime network directory
`/run` is temporary and `/usr/lib` is for vendors
symlink with the same name pointing to `/dev/null` disables the configuration file entirely

`bridge` A bridge device is a software switch, and each of its slave devices and the bridge itself are ports of the switch.
`tap` A persistent Level 2 tunnel between a network device and a device node.
`tun` A persistent Level 3 tunnel between a network device and a device node.
`veth` An Ethernet tunnel between a pair of network devices.
`sit` An IPv6 over IPv4 tunnel.
`vti` An IPv4 over IPSec tunnel.

[NetDev]
Name=bridge0
Kind=bridge
[Match]
Virtualization=no

[NetDev]
Name=dummy-test
Kind=dummy
MACAddress=12:34:56:78:9a:bc

[NetDev]
Name=vlan1
Kind=vlan
[VLAN]
Id=1

[NetDev]
Name=macvtap-test
Kind=macvtap
Compare with macvtap.network below.

[Match]
Name=enp2s0
[Network]
Address=192.168.0.15/24
Gateway=192.168.0.1

[Match]
Name=en*
[Network]
DHCP=yes
# /etc/systemd/network/25-bridge-static.network
[Match]
Name=bridge0
[Network]
...
# /etc/systemd/network/25-bridge-slave-interface-1.network
[Match]
Name=enp2s0
[Network]
Bridge=bridge0
# /etc/systemd/network/25-bridge-slave-interface-x.network

[Match]
Name=enp2s0
[Network]
Bridge=bridge0
[BridgeVLAN]
VLAN=1-32
PVID=42
EgressUntagged=42
[BridgeVLAN]
VLAN=100-200
[BridgeVLAN]
EgressUntagged=300-400
VLAN=
The VLAN ID allowed on the port.
EgressUntagged=
The VLAN ID specified here will be used to untag frames on egress.
Configuring EgressUntagged= implicates the use of VLAN= above and will enable the VLAN ID for ingress as well.
PVID=
The Port VLAN ID specified here is assigned to all untagged frames at ingress. PVID= can be used only once.
Configuring PVID= implicates the use of VLAN= above and will enable the VLAN ID for ingress as well.

[Match]
Name=enp0s25
[Network]
MACVTAP=macvtap-test

Network link configuration is performed by the net_setup_link udev builtin. udev (userspace /dev) is a device manager for the Linux kernel. As the successor of devfsd and hotplug, udev primarily manages device nodes in the /dev directory.
Last modified 1yr ago
Copy link
Edit on GitHub
On this page
systemctl
Units
target
Config
add
debug
journald
systemd-networkd.service
systemd.netdev
Kind
Examples
systemd.network
static.network
dhcp.network
A bridge with two enslaved links
bridge-slave-interface-vlan.network
macvtap.network
systemd.link