Linux Command Reference ยท Systemd and Logging (Read-Only)
systemctl status
Reference for systemctl status: how to read the Active, Loaded, Main PID and log lines, exit codes of is-active and is-failed, and use status in scripts. Read-only.
systemctl status prints a snapshot of one systemd unit (usually a service): whether it is loaded, enabled and running, its main process and control group, resource use, and the last few log lines from the journal. It is the first command to run when a service misbehaves.
This page is read-only: the example sandbox has no systemd, so the console output below is shown as sample text, and the live examples work with that text and with the exit-code conventions that scripts rely on.
systemctl status nginx systemctl status --no-pager -l ssh systemctl is-active nginx
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Syntax
systemctl [--user] status [UNIT...|PID...] [--no-pager] [-l] [-n LINES]
| Option | Description |
|---|---|
UNIT |
Unit name; .service is assumed if you omit the suffix. |
PID |
Show the unit that owns that process. |
| no argument | Show overall system state and a tree of running units. |
--no-pager |
Print directly instead of opening less. |
-l, --full |
Do not shorten long lines (default in recent versions). |
-n N |
Number of journal lines to show (default 10). |
--user |
Query the per-user service manager. |
Reading the key lines:
| Line | Meaning |
|---|---|
Loaded: |
Unit file path and whether it is enabled (starts at boot), disabled, static (no install section) or masked (blocked). |
Active: |
active (running), active (exited) for one-shot jobs, activating, inactive (dead), or failed. |
Main PID: |
The process systemd tracks; (code=exited, status=1/FAILURE) shows why it stopped. |
CGroup: |
All processes of the unit, as a tree. |
| Log lines | Recent journal messages for the unit. |
Usage notes
- Exit status:
statusreturns 0 when the unit is running and 3 when it is not, so it works in scripts, butsystemctl is-activeandis-failedare cleaner (they print one word and have the same codes). - Truncated logs: only the newest lines show. Use
journalctl -u UNITfor the full history, and-bfor the current boot. failedstates:Result=exit-code,signal,timeoutorstart-limit-hittells you the category. After fixing the cause, clear it withsudo systemctl reset-failed UNIT.- Does not need root to read, but some log lines may be hidden unless you are in the
systemd-journaloradmgroup. - Pager: output goes through
less; use--no-pagerin scripts, or setSYSTEMD_PAGER=cat. active (exited)is normal for services that run a command once and leave state behind, such as mounting or firewall rule loaders.- Containers often have no systemd; see
servicefor older init systems.
Related
systemctl,journalctl,service,/run- Lessons: Packages and services, Logging with journald