Rain Wiki · Linux

systemd units and systemctl

What a systemd unit is, the common unit types, and how to start, stop, enable and inspect services with systemctl.

Linux · Rain Wiki

A systemd unit is a configuration object that systemd, the init system of most Linux distributions, manages: services, sockets, timers, mounts and more. Units are described by unit files such as /etc/systemd/system/<name>.service and controlled with the systemctl command.

Unit types

.service runs a program, .socket starts a service when a connection arrives, .timer runs a unit on a schedule, .mount and .automount handle file systems, .target groups units into states such as multi-user.target.

Where unit files live

Packages install units in /usr/lib/systemd/system (or /lib/systemd/system). Local changes belong in /etc/systemd/system, which takes precedence. 'systemctl edit <unit>' creates a drop-in override instead of changing the packaged file.

Everyday commands

'systemctl status <unit>' shows state and the last log lines. 'start', 'stop' and 'restart' act now; 'enable' and 'disable' control starting at boot; 'enable --now' does both. 'systemctl --failed' lists failed units, and 'systemctl daemon-reload' rereads unit files after changes.

How to check a failing service

  1. List failed units: systemctl --failed
  2. Show the state and recent messages: systemctl status <unit>
  3. Read the full log of this boot: journalctl -u <unit> -b
  4. After fixing the configuration: sudo systemctl restart <unit>

Cautions

  • Change packaged units with 'systemctl edit', not by editing files in /usr/lib/systemd/system: updates overwrite them.
  • Do not disable units you do not know, such as systemd-journald or dbus.

Sources

Last updated: 2026-10-08

Related articles