CmdKeys LogoCommand Quiz

Systemd Command Practice

systemd starts units and writes their logs to the journal. This track drills systemctl start/stop/enable/mask plus journalctl -u/-f/-b — the commands you type on a host, not a container dashboard. Docker manages containers; systemctl manages services on the machine.

Command Reference

unit

CommandDescription
systemctl start <name>Start a unit immediately without changing whether it starts at boot.
systemctl stop <name>Stop a running unit immediately.
systemctl status <name>Show whether a unit is active and print its recent journal lines.
systemctl restart <name>Stop a unit if needed, then start it again.
systemctl reload <name>Ask a running unit to reload its configuration without a full restart.
systemctl daemon-reloadReload systemd's unit files from disk after a unit file change.

power

CommandDescription
systemctl rebootReboot the machine through systemd.
systemctl poweroffHalt and power off the machine.
systemctl haltStop all software and leave the hardware powered on.
systemctl hibernateWrite memory to disk and power off the hardware.

enable

CommandDescription
systemctl enable <name>Link a unit so it starts at boot; do not start it now.
systemctl disable <name>Remove the boot symlink so the unit does not start at boot.
systemctl enable --now <name>Enable a unit at boot and start it immediately.
systemctl disable --now <name>Disable a unit at boot and stop it immediately.
systemctl mask <name>Point a unit at /dev/null so nothing can start it until it is unmasked.
systemctl unmask <name>Remove a mask so the unit can be started again.

logs

CommandDescription
journalctlPrint the entire journal, oldest entries first.
journalctl -bPrint journal entries from the current boot only.
journalctl -u <name>Print journal entries for one unit.
journalctl -n <num>Print only the last N journal entries.
journalctl -fPrint new journal entries as they arrive.
journalctl -b -1Print journal entries from the previous boot.
journalctl --since todayPrint journal entries since the start of today.
journalctl -p err..emergPrint only error-and-above priority journal entries.

inspect

CommandDescription
systemctl list-unitsList units that are currently loaded/active.
systemctl list-unit-filesList installed unit files and whether each is enabled.
systemctl is-active <name>Print whether a unit is currently active (exit status reflects the answer).
systemctl --failedList units that are in the failed state.
systemctl is-enabled <name>Print whether a unit is enabled to start at boot.
systemctl cat <name>Print the contents and path of a unit file as systemd sees it.

Key Use Cases

  • Start a unit now without changing whether it starts at boot
  • Enable a unit at boot and start it in one command (--now)
  • Mask a unit so even start and dependencies cannot pull it in
  • List failed units after a bad deploy
  • Follow one service's journal in real time
  • Read logs from the previous boot after a crash

Frequently Asked Questions

What is the difference between start and enable?

start runs the unit now and does not change boot. enable links the unit so it starts on boot and does not start it now unless you pass --now.

How is mask different from disable?

disable removes the boot symlink. mask points the unit at /dev/null so start and other units cannot activate it until you unmask.

Why journalctl instead of /var/log files?

systemd units log to the journal. journalctl -u filters by unit; -b is this boot; -f follows. Those filters are not grep on syslog.

When do I run daemon-reload?

After you add or edit a unit file on disk. It reloads systemd's unit list; it does not restart the service (that is restart or reload).

Ready to master Systemd commands?

Test your muscle memory with our spaced-repetition quiz system. Free forever.

Start Practice Now →