LinuxCommandLibrary

systemctl-status

Show systemd unit status

TLDR

Show the status of a systemd unit

$ systemctl status [unit].[service|timer|socket|target|...]
copy

Show the status of failed units
$ systemctl status --failed
copy

List all running services
$ systemctl status
copy

List all units in the system
$ systemctl status --all
copy

List all units of a specific type
$ systemctl status --type [service|timer|socket|target|...]
copy

List all units with a specific state
$ systemctl status --state [active|inactive|failed]
copy

SYNOPSIS

systemctl status [OPTIONS...] [UNIT...]

Displays status for specified UNITs. If no UNIT is given, a short system status is shown.

PARAMETERS

--no-pager
    Do not pipe output into a pager (e.g., 'less').

--full, -l
    Show full output lines without truncation.

--lines=
    Control the number of journal lines shown in the output.

--output=
    Format the journal output, e.g., 'json', 'short', 'cat'.

--user
    Operate on the user systemd instance, not the system-wide one.

DESCRIPTION

systemctl status is a fundamental command for inspecting the current state of systemd units on a Linux system. It provides a detailed overview of whether a service, socket, mount point, or other unit type is active, loaded, and enabled.

When invoked with a specific unit name (e.g., `apache2.service`), it displays its `Loaded`, `Active`, and `Sub` states, recent log entries from `journalctl`, process IDs (`Main PID`), and CGroup information. This command is invaluable for troubleshooting services, verifying their operation, and understanding their runtime behavior. Without a specified unit, it provides a concise summary of the overall system status, often highlighting failed units. Its output is typically paginated, allowing for easy navigation through potentially long logs and status details. It serves as the primary tool for administrators and developers to monitor the health and performance of their system's components managed by systemd.

CAVEATS

systemctl status typically requires root privileges or `sudo` to view status for most system-wide units. Output can be extensive and is often piped to a pager like `less`, which might require pressing `q` to exit. If a specified unit does not exist or its name is incorrect, the command will report "Unit UNIT_NAME could not be found."

INTERPRETING OUTPUT FIELDS

When viewing the status of a specific unit, you'll see several key fields:

  • Loaded: Indicates if the unit definition file was loaded. (loaded) means it's recognized.
  • Active: Shows the unit's runtime state. (active) indicates running; (inactive) stopped; (failed) encountered an error.
  • Docs: Provides links to relevant documentation, if available.
  • Main PID: The Process ID of the unit's main process.
  • CGroup: The control group path for the unit, useful for resource management.
  • Lines from journal: Recent log entries related to the unit, providing valuable insight into its operations and any errors.

HISTORY

systemctl and the broader systemd init system were developed as replacements for the traditional SysVinit and Upstart systems. Introduced in 2010 and widely adopted, `systemd` aimed to improve boot times, provide better dependency management, and offer more comprehensive service control. systemctl status emerged as the direct successor to commands like `service status` (from SysVinit) or checking process lists, offering a unified and richer interface for monitoring system components.

SEE ALSO

journalctl(1): For comprehensive log analysis and filtering., systemctl(1): The main command for controlling the systemd system and service manager., systemctl start(1): To start (activate) units., systemctl stop(1): To stop (deactivate) units., systemctl enable(1): To configure units to start automatically at boot.

Copied to clipboard