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 nginxsystemctl stop <service> — Stop a running service.
systemctl stop nginxsystemctl restart <service> — Stop and then start a service. Causes a brief downtime.
systemctl restart nginxsystemctl reload <service> — Reload configuration without stopping the service (zero downtime, if supported).
systemctl reload nginxsystemctl reload-or-restart <service> — Reload if the service supports it, otherwise restart.
systemctl reload-or-restart php-fpmsystemctl try-restart <service> — Restart a service only if it is currently running.
systemctl try-restart nginxsystemctl kill <service> — Send a signal to a service's processes. Default signal is SIGTERM.
systemctl kill nginxsystemctl kill -s SIGKILL <service> — Force kill a service by sending SIGKILL to all its processes.
systemctl kill -s SIGKILL stuck-serviceEnable & Disable (Boot Behavior)
systemctl enable <service> — Enable a service to start automatically at boot.
systemctl enable nginxsystemctl disable <service> — Disable a service from starting at boot.
systemctl disable nginxsystemctl enable --now <service> — Enable at boot and start immediately in one command.
systemctl enable --now nginxsystemctl disable --now <service> — Disable at boot and stop immediately in one command.
systemctl disable --now nginxsystemctl is-enabled <service> — Check if a service is enabled for automatic start at boot.
systemctl is-enabled nginxsystemctl reenable <service> — Disable and re-enable a service. Useful after changing the [Install] section.
systemctl reenable nginxsystemctl mask <service> — Completely prevent a service from being started (even manually). Links unit to /dev/null.
systemctl mask bluetoothsystemctl unmask <service> — Remove the mask and allow the service to be started again.
systemctl unmask bluetoothService Status & Inspection
systemctl status <service> — Show detailed status including state, PID, memory usage, and recent log lines.
systemctl status nginxsystemctl is-active <service> — Check if a service is currently running. Returns active or inactive.
systemctl is-active nginxsystemctl is-failed <service> — Check if a service has failed.
systemctl is-failed nginxsystemctl show <service> — Show all properties of a service in key=value format.
systemctl show nginxsystemctl show <service> -p <property> — Show a specific property of a service.
systemctl show nginx -p MainPIDsystemctl show <service> -p ActiveState,SubState — Show multiple specific properties at once.
systemctl show nginx -p ActiveState,SubState,MainPIDsystemctl cat <service> — Display the full unit file content of a service.
systemctl cat nginxsystemctl help <service> — Open the man page associated with a service (if available).
systemctl help sshdListing Units
systemctl list-units — List all loaded and active units.
systemctl list-unitssystemctl list-units --type=service — List only service units.
systemctl list-units --type=servicesystemctl list-units --state=running — List only currently running units.
systemctl list-units --state=runningsystemctl list-units --state=failed — List all units that have failed.
systemctl list-units --state=failedsystemctl list-units --all — List all units including inactive ones.
systemctl list-units --allsystemctl list-unit-files — List all installed unit files with their enabled/disabled state.
systemctl list-unit-filessystemctl list-unit-files --type=service — List only service unit files with their state.
systemctl list-unit-files --type=servicesystemctl list-unit-files --state=enabled — List only enabled unit files.
systemctl list-unit-files --state=enabledDependencies & Order
systemctl list-dependencies <service> — Show a tree of units that a service depends on.
systemctl list-dependencies nginxsystemctl list-dependencies <service> --reverse — Show which units depend on (require) this service.
systemctl list-dependencies nginx --reversesystemctl list-dependencies <service> --before — Show units that this service starts before.
systemctl list-dependencies nginx --beforesystemctl list-dependencies <service> --after — Show units that this service starts after.
systemctl list-dependencies nginx --afterUnit File Management
systemctl edit <service> — Create a drop-in override file for a service (opens editor). Changes survive package updates.
systemctl edit nginxsystemctl edit --full <service> — Edit the full unit file directly (not a drop-in). Overrides will NOT survive package updates.
systemctl edit --full nginxsystemctl daemon-reload — Reload systemd manager configuration after modifying unit files. Required after any manual edit.
systemctl daemon-reloadsystemctl revert <service> — Remove all local customizations (drop-ins) and revert to the vendor unit file.
systemctl revert nginxsystemd-analyze verify <unit_file> — Check a unit file for syntax errors and common issues.
systemd-analyze verify /etc/systemd/system/my-app.serviceTimers (Cron Replacement)
systemctl list-timers — List all active timers with their next and last trigger times.
systemctl list-timerssystemctl list-timers --all — List all timers including inactive ones.
systemctl list-timers --allsystemctl start <timer> — Start a timer immediately.
systemctl start backup.timersystemctl enable --now <timer> — Enable a timer to persist across reboots and start it now.
systemctl enable --now backup.timersystemctl status <timer> — Show timer status including next scheduled run.
systemctl status backup.timersystemd-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.shsystemd-run --on-active=<time> <command> — Create a transient timer that runs once after a delay.
systemd-run --on-active=30m /usr/local/bin/cleanup.shJournalctl (Logs)
journalctl -u <service> — Show all log entries for a specific service.
journalctl -u nginxjournalctl -u <service> -f — Follow (tail) live log output for a service.
journalctl -u nginx -fjournalctl -u <service> -n <lines> — Show only the last N log lines for a service.
journalctl -u nginx -n 50journalctl -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 errjournalctl -u <service> -o json-pretty — Output logs in pretty-printed JSON format.
journalctl -u nginx -o json-prettyjournalctl -u <service> --no-pager — Output logs without using a pager (useful for piping).
journalctl -u nginx --no-pager | grep errorjournalctl -b — Show all logs from the current boot.
journalctl -bjournalctl -b -1 — Show logs from the previous boot.
journalctl -b -1journalctl --list-boots — List all recorded boot sessions.
journalctl --list-bootsjournalctl --disk-usage — Show how much disk space the journal logs consume.
journalctl --disk-usagejournalctl --vacuum-size=<size> — Reduce journal log storage to a maximum size.
journalctl --vacuum-size=500Mjournalctl --vacuum-time=<time> — Remove journal entries older than the specified time.
journalctl --vacuum-time=30dSystem State & Targets
systemctl get-default — Show the default boot target (e.g. graphical.target, multi-user.target).
systemctl get-defaultsystemctl set-default <target> — Set the default boot target.
systemctl set-default multi-user.targetsystemctl isolate <target> — Switch to a different target immediately (like changing runlevel).
systemctl isolate multi-user.targetsystemctl list-units --type=target — List all active targets.
systemctl list-units --type=targetsystemctl reboot — Reboot the system.
systemctl rebootsystemctl poweroff — Shut down and power off the system.
systemctl poweroffsystemctl suspend — Suspend the system to RAM.
systemctl suspendsystemctl hibernate — Hibernate the system to disk.
systemctl hibernateAnalyze & Performance
systemd-analyze — Show how long the system boot took (kernel + userspace).
systemd-analyzesystemd-analyze blame — List all services by startup time, slowest first.
systemd-analyze blamesystemd-analyze critical-chain — Show the critical chain of units that delayed the boot the most.
systemd-analyze critical-chainsystemd-analyze critical-chain <service> — Show the critical chain for a specific service.
systemd-analyze critical-chain nginx.servicesystemd-analyze plot > boot.svg — Generate an SVG chart of the boot process for visual analysis.
systemd-analyze plot > boot.svgsystemd-analyze security <service> — Analyze the security and sandboxing settings of a service.
systemd-analyze security nginxUser Services
systemctl --user start <service> — Start a user-level service (no root required).
systemctl --user start my-appsystemctl --user enable --now <service> — Enable and start a user-level service.
systemctl --user enable --now my-appsystemctl --user status <service> — Show the status of a user-level service.
systemctl --user status my-appsystemctl --user list-units --type=service — List all user-level services.
systemctl --user list-units --type=servicesystemctl --user daemon-reload — Reload user-level systemd configuration after editing unit files.
systemctl --user daemon-reloadloginctl 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
- systemctl manual page – the official systemctl reference covering every subcommand and option
- Arch Wiki: systemd – comprehensive guide to systemd, units and timers
Related Commands
- 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