Systemd

Systemd

Status and messages

1
systemctl --user --failed status

Show kernel / dmesg messages with priority error or higher from last boot in json format, grep for AMD.

1
2
journalctl --priority=err --dmesg --output=json --boot=-1 --grep=AMD
journalctl -perr -k -o json -b-1 -g AMD

Show user logs since midnight, jump to end of messages.

1
journalctl --user --pager-end --since today

Show only warnings (level 4) for a unit.

1
journalctl -p4..4 -u nginx.service

Enable unit start on boot and restart changed unit.

1
2
3
systemctl --user enable mpd.service
systemctl --user daemon-reload
systemctl --user restart mpd.service

Inspection, formats

1
2
3
4
5
systemctl --version
systemctl whoami
systemd-cat mpd.service
systemctl show mpd
systemd-analyze unit-files

Systemd timer, time specifications.

1
systemd-analyze calendar '*-*-* *:*:00'

Control group info.

1
2
systemd-cgls
systemd-cgtop

Help

In addition to command named manual pages, there are many systemd* named pages.

1
2
man systemd-sleep
man systemd.directives
1
systemctl --help

Configuration and files

1
2
3
4
5
6
/etc/systemd/
# System wide units
/usr/lib/systemd/system/ # upstream from distro
/etc/systemd/system/ # user defined
# Per user units
$XDG_CONFIG_HOME/systemd/user/

Units

1
man systemd.unit

Services

Services can be instantiated.

1
systemctl status nut-driver@mustek.service

Directives in files have valid contexts.

Limit memory use in a unit
1
MemoryMax=bytes
1
man systemd.resource-control