How to check whether a service is active using systemctl

Checking whether a systemd service is active confirms whether a daemon is currently running and able to serve its expected role. This quick check is useful before a restart, after a boot, during a deployment, or while narrowing down why a dependent application is not responding.

systemctl is-active asks systemd for the unit's current active state and prints a short result such as active or inactive. When a shorter machine-readable check is needed, the --quiet option suppresses text output and relies on the command exit status instead, while systemctl show exposes the separate ActiveState and SubState values for more detail.

Examples below use Ubuntu 24.04 with OpenSSH as the sample service unit, so the commands refer to ssh.service. Other distributions may use a different unit name such as sshd.service, and companion units such as sockets can remain active even after the service unit itself becomes inactive, so checking the exact unit name and reading the detailed status view avoids wrong conclusions.

Steps to check whether a systemd service is active:

  1. Open a terminal on the Linux host that runs systemd.
  2. List matching service units when the exact unit name is not certain.
    $ systemctl list-unit-files --type=service 'ssh*' --no-pager --no-legend
    ssh.service  enabled enabled
    sshd.service alias   -

    On Ubuntu, OpenSSH commonly uses ssh.service, while many other Linux distributions expose the same daemon as sshd.service.

  3. Check the service active state with systemctl.
    $ systemctl is-active ssh.service
    active

    The command prints the current active state to standard output unless --quiet is used.

  4. Read the high-level and low-level state when the short result needs more detail.
    $ systemctl show --property=ActiveState --property=SubState ssh.service
    ActiveState=active
    SubState=running

    ActiveState reports the broad service state, while SubState shows the more specific runtime condition such as running or dead.

  5. Use the quiet form when the check is part of a script or a health probe.
    $ systemctl is-active --quiet ssh.service
    $ echo $?
    0

    Exit status 0 means the unit is active, while 3 means the unit is not active; current systemd documentation recommends checking the explicit unit state when the numeric code alone is not enough.

  6. Inspect the detailed status when the result is not active or the reason is unclear.
    $ systemctl status ssh.service --no-pager
    ○ ssh.service - OpenBSD Secure Shell server
         Loaded: loaded (/usr/lib/systemd/system/ssh.service; enabled; preset: enabled)
         Active: inactive (dead) since Mon 2026-04-13 08:56:39 UTC; 7s ago
       Duration: 2min 8.846s
    TriggeredBy: ● ssh.socket
           Docs: man:sshd(8)
                 man:sshd_config(5)
        Process: 204 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
        Process: 205 ExecStart=/usr/sbin/sshd -D $SSHD_OPTS (code=exited, status=0/SUCCESS)
       Main PID: 205 (code=exited, status=0/SUCCESS)
            CPU: 290ms
    ##### snipped #####

    Common systemd active states include active, inactive, activating, deactivating, and failed.

    Companion units such as .socket units can stay active while the service unit is inactive, so read the unit name on the Active: line instead of assuming the whole feature is fully stopped or started.