- Power off the system
- Reboot the system
- Suspend the system
- Hibernate the system
- Hibernate and suspend the system
- Action on power button
- Can be configured in /etc/systemd/logind.conf by HandlePowerKey.
- Action on LID switch
- Can be configured in /etc/systemd/logind.conf by HandleLidSwitch.
- Reload configuration after changes
systemctl [--user] reload-daemon
--user Reload only user configuration.
- Automatic start-up of systemd user instances
loginctl enable-linger user-name
- Start/stop service
systemctl start|stop <servicename>
- Restart service
systemctl restart <servicename>
- Restart if service is already running.
systemctl condrestart <servicename>
- Reload configuration files
systemctl reload <servicename>
- Start service at boot
systemctl enable <servicename>
- Prevent service start at boot
systemctl disable <servicename>
- Check if service is configured to autostart.
systemctl is-enabled <servicename>
Analyze and debug
- Show system status
- List running units
- List failed units.
- Find long running services
- Plot dependency graph as SVG
systemd-analyze plot > graph.svg
You can override or extend an existing system unit, for example to add additional dependencies or change the executable arguments.
- Modify unit
systemctl edit sshd
Opens /etc/systemd/system/sshd.d/override.conf and reloads the unit when done editing.
- Replace unit
systemctl edit --full sshd
Opens /etc/systemd/system/sshd (copying installed version) and reloads the unit when done editing.
- Revert to vendor version
systemctl revert sshd
- Show effective unit
systemctl cat sshd
Show content of unit after apply all overrides.
- Find differences
Show diff for modified unit files.
- Determine which target is used by default.
- Set the default target (runlevel).
systemctl set-default multi-user.target
- Switch to another runlevel (target).
systemctl isolate graphical.target
Timers are a replacement for cronjob.
- List timers
- Create timer
- Create new unit: https://wiki.archlinux.org/index.php/Systemd/Timers
- Show complete log
-r Show log in reverse order.
-x Show explainations for log entries.
-e Force pager to show the last page.
- Show log for specific unit
journalctl -u postfix
- Write to log from shell
echo "Hello World" | systemd-cat -t my-tag -p info
logger is still possible with journald, but system-cat has more features.
- Start program and redirect stdout to log
- Show log by unit pattern
journalctl -u postfix* -u dovecot*
- Watch for new log entries (follow)
journalctl -u nginx* -f
- Filter by priority
journalctl -u ntp -p emerg..warning
emerg 0 alert 1 crit 2 err 3 warning 4 notice 5 info 6 debug 7
- Show all critical logs
journalctl -p crit
- Filter by date
journalctl -u postfix -S "-5 minutes"or
journalctl -u postfix -S "today"
- Show only kernel messages
- Systemd's journald replaces the old syslog daemons.
- Basically this is done by providing /dev/log which is connected to journald.
- The syslog() API writes to /dev/log and thus messages are forwared to journald.
- Persistent logs
Important: journald default configuration is to keep all log messages in memory (lost after a reboot).
Change /etc/systemd/journald.conf to make journal persistent.
If rsyslog is installed, default behavior for systemd is to forward log messages to rsyslog which can filter and store messages in well known locations like /var/log/auth.log.
- System units
/usr/lib/systemd/system/ ⁘ Units provided by installed packages /etc/systemd/system/ ⁘ Units installed by the sysadmin
- User units
/etc/systemd/user/ ⁘ System-wide user units installed by the sysadmin ~/.local/share/systemd/user/ ⁘ Units provided by user-installed packages ~/.config/systemd/user/ ⁘ Custom user units installed by users