systemctl — Control systemd Services and Units

Practical guide to systemctl — start, stop, enable and inspect services, manage units, targets and timers, and control system state.

systemctl is the central tool for controlling the systemd init and service manager – from individual services to the entire system state. You start, stop and reload services, enable them for automatic startup, check their status, and work with units, targets, timers and logs. This guide walks you through the commands you actually reach for in everyday server work, from a quick restart to boot analysis with systemd-analyze.

Service Control

systemctl start <service> — Start a service immediately.

systemctl start nginx

systemctl stop <service> — Stop a running service.

systemctl stop nginx

systemctl restart <service> — Stop and then start a service. Causes a brief downtime.

systemctl restart nginx

systemctl reload <service> — Reload configuration without stopping the service (zero downtime, if supported).

systemctl reload nginx

systemctl reload-or-restart <service> — Reload if the service supports it, otherwise restart.

systemctl reload-or-restart php-fpm

systemctl try-restart <service> — Restart a service only if it is currently running.

systemctl try-restart nginx

systemctl kill <service> — Send a signal to a service's processes. Default signal is SIGTERM.

systemctl kill nginx

systemctl kill -s SIGKILL <service> — Force kill a service by sending SIGKILL to all its processes.

systemctl kill -s SIGKILL stuck-service

Enable & Disable (Boot Behavior)

systemctl enable <service> — Enable a service to start automatically at boot.

systemctl enable nginx

systemctl disable <service> — Disable a service from starting at boot.

systemctl disable nginx

systemctl enable --now <service> — Enable at boot and start immediately in one command.

systemctl enable --now nginx

systemctl disable --now <service> — Disable at boot and stop immediately in one command.

systemctl disable --now nginx

systemctl is-enabled <service> — Check if a service is enabled for automatic start at boot.

systemctl is-enabled nginx

systemctl reenable <service> — Disable and re-enable a service. Useful after changing the [Install] section.

systemctl reenable nginx

systemctl mask <service> — Completely prevent a service from being started (even manually). Links unit to /dev/null.

systemctl mask bluetooth

systemctl unmask <service> — Remove the mask and allow the service to be started again.

systemctl unmask bluetooth

Service Status & Inspection

systemctl status <service> — Show detailed status including state, PID, memory usage, and recent log lines.

systemctl status nginx

systemctl is-active <service> — Check if a service is currently running. Returns active or inactive.

systemctl is-active nginx

systemctl is-failed <service> — Check if a service has failed.

systemctl is-failed nginx

systemctl show <service> — Show all properties of a service in key=value format.

systemctl show nginx

systemctl show <service> -p <property> — Show a specific property of a service.

systemctl show nginx -p MainPID

systemctl show <service> -p ActiveState,SubState — Show multiple specific properties at once.

systemctl show nginx -p ActiveState,SubState,MainPID

systemctl cat <service> — Display the full unit file content of a service.

systemctl cat nginx

systemctl help <service> — Open the man page associated with a service (if available).

systemctl help sshd

Listing Units

systemctl list-units — List all loaded and active units.

systemctl list-units

systemctl list-units --type=service — List only service units.

systemctl list-units --type=service

systemctl list-units --state=running — List only currently running units.

systemctl list-units --state=running

systemctl list-units --state=failed — List all units that have failed.

systemctl list-units --state=failed

systemctl list-units --all — List all units including inactive ones.

systemctl list-units --all

systemctl list-unit-files — List all installed unit files with their enabled/disabled state.

systemctl list-unit-files

systemctl list-unit-files --type=service — List only service unit files with their state.

systemctl list-unit-files --type=service

systemctl list-unit-files --state=enabled — List only enabled unit files.

systemctl list-unit-files --state=enabled

Dependencies & Order

systemctl list-dependencies <service> — Show a tree of units that a service depends on.

systemctl list-dependencies nginx

systemctl list-dependencies <service> --reverse — Show which units depend on (require) this service.

systemctl list-dependencies nginx --reverse

systemctl list-dependencies <service> --before — Show units that this service starts before.

systemctl list-dependencies nginx --before

systemctl list-dependencies <service> --after — Show units that this service starts after.

systemctl list-dependencies nginx --after

Unit File Management

systemctl edit <service> — Create a drop-in override file for a service (opens editor). Changes survive package updates.

systemctl edit nginx

systemctl edit --full <service> — Edit the full unit file directly (not a drop-in). Overrides will NOT survive package updates.

systemctl edit --full nginx

systemctl daemon-reload — Reload systemd manager configuration after modifying unit files. Required after any manual edit.

systemctl daemon-reload

systemctl revert <service> — Remove all local customizations (drop-ins) and revert to the vendor unit file.

systemctl revert nginx

systemd-analyze verify <unit_file> — Check a unit file for syntax errors and common issues.

systemd-analyze verify /etc/systemd/system/my-app.service

Timers (Cron Replacement)

systemctl list-timers — List all active timers with their next and last trigger times.

systemctl list-timers

systemctl list-timers --all — List all timers including inactive ones.

systemctl list-timers --all

systemctl start <timer> — Start a timer immediately.

systemctl start backup.timer

systemctl enable --now <timer> — Enable a timer to persist across reboots and start it now.

systemctl enable --now backup.timer

systemctl status <timer> — Show timer status including next scheduled run.

systemctl status backup.timer

systemd-analyze calendar '<expression>' — Test and parse a calendar expression to see when it would trigger.

systemd-analyze calendar 'Mon..Fri *-*-* 06:00:00'

systemd-run --on-calendar='<expression>' <command> — Create a transient timer that runs a command on a schedule.

systemd-run --on-calendar='*-*-* 02:00:00' /usr/local/bin/backup.sh

systemd-run --on-active=<time> <command> — Create a transient timer that runs once after a delay.

systemd-run --on-active=30m /usr/local/bin/cleanup.sh

Journalctl (Logs)

journalctl -u <service> — Show all log entries for a specific service.

journalctl -u nginx

journalctl -u <service> -f — Follow (tail) live log output for a service.

journalctl -u nginx -f

journalctl -u <service> -n <lines> — Show only the last N log lines for a service.

journalctl -u nginx -n 50

journalctl -u <service> --since '<time>' — Show logs since a specific time.

journalctl -u nginx --since '1 hour ago'

journalctl -u <service> --since '<start>' --until '<end>' — Show logs within a time range.

journalctl -u nginx --since '2024-01-01' --until '2024-01-02'

journalctl -u <service> -p <priority> — Filter logs by priority: emerg, alert, crit, err, warning, notice, info, debug.

journalctl -u nginx -p err

journalctl -u <service> -o json-pretty — Output logs in pretty-printed JSON format.

journalctl -u nginx -o json-pretty

journalctl -u <service> --no-pager — Output logs without using a pager (useful for piping).

journalctl -u nginx --no-pager | grep error

journalctl -b — Show all logs from the current boot.

journalctl -b

journalctl -b -1 — Show logs from the previous boot.

journalctl -b -1

journalctl --list-boots — List all recorded boot sessions.

journalctl --list-boots

journalctl --disk-usage — Show how much disk space the journal logs consume.

journalctl --disk-usage

journalctl --vacuum-size=<size> — Reduce journal log storage to a maximum size.

journalctl --vacuum-size=500M

journalctl --vacuum-time=<time> — Remove journal entries older than the specified time.

journalctl --vacuum-time=30d

System State & Targets

systemctl get-default — Show the default boot target (e.g. graphical.target, multi-user.target).

systemctl get-default

systemctl set-default <target> — Set the default boot target.

systemctl set-default multi-user.target

systemctl isolate <target> — Switch to a different target immediately (like changing runlevel).

systemctl isolate multi-user.target

systemctl list-units --type=target — List all active targets.

systemctl list-units --type=target

systemctl reboot — Reboot the system.

systemctl reboot

systemctl poweroff — Shut down and power off the system.

systemctl poweroff

systemctl suspend — Suspend the system to RAM.

systemctl suspend

systemctl hibernate — Hibernate the system to disk.

systemctl hibernate

Analyze & Performance

systemd-analyze — Show how long the system boot took (kernel + userspace).

systemd-analyze

systemd-analyze blame — List all services by startup time, slowest first.

systemd-analyze blame

systemd-analyze critical-chain — Show the critical chain of units that delayed the boot the most.

systemd-analyze critical-chain

systemd-analyze critical-chain <service> — Show the critical chain for a specific service.

systemd-analyze critical-chain nginx.service

systemd-analyze plot > boot.svg — Generate an SVG chart of the boot process for visual analysis.

systemd-analyze plot > boot.svg

systemd-analyze security <service> — Analyze the security and sandboxing settings of a service.

systemd-analyze security nginx

User Services

systemctl --user start <service> — Start a user-level service (no root required).

systemctl --user start my-app

systemctl --user enable --now <service> — Enable and start a user-level service.

systemctl --user enable --now my-app

systemctl --user status <service> — Show the status of a user-level service.

systemctl --user status my-app

systemctl --user list-units --type=service — List all user-level services.

systemctl --user list-units --type=service

systemctl --user daemon-reload — Reload user-level systemd configuration after editing unit files.

systemctl --user daemon-reload

loginctl enable-linger <user> — Allow user services to run even when the user is not logged in.

loginctl enable-linger deploy

Conclusion

systemctl bundles the entire service control of systemd into one consistent command – for everyday work, start, stop, restart, reload and status already take you a long way. The key distinction is between enable/disable (autostart at boot) and start/stop (immediate effect right now); enable --now combines both in a single step. After any change to unit files, run systemctl daemon-reload, and list-units --failed quickly shows you what is broken. Be careful with critical services: a stop, disable or mask on sshd or the network can cut off access or the next boot on a remote server. reboot, poweroff and isolate also reach deep into the system – and most write actions require sudo. Your own user services you manage entirely without root via systemctl --user.

Further Reading

  • journalctl – query logs from systemd services and the journal
  • loginctl – manage user sessions and logins via systemd-logind
  • hostnamectl – query and set the hostname and system information via systemd