Website Vidya
Linux & ServersStep-by-Step Guide

List Linux Services with systemctl: Status, Units, and States

Learn list linux services with syntax, essential flags, practical terminal examples, real-world sysadmin workflows, security tips, and troubleshooting.

RR
Rajesh RayLead Systems Educator
Published:
10 min read
PDF Cheat Sheet
List Linux Services with systemctl: Status, Units, and States
AI Executive SummaryWebsiteVidya AI

10 min read

Learn list linux services with syntax, essential flags, practical terminal examples, real-world sysadmin workflows, security tips, and troubleshooting.

Key Highlights
  • What systemctl Does and When to Use It
  • Availability and Installation Across Linux Distributions
  • Command Syntax, Arguments, and Exit Status Codes
Grounded in full engineering runbookWebsiteVidya AI Engine

Interactive Builder for this Guide

Build your custom systemd syntax (List Linux Services with systemctl: Status, Units, and States)

Generated Config Output
[Unit]
Description=Core API Node Service
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=www-data
WorkingDirectory=/opt/myapp
EnvironmentFile=/opt/myapp/.env
ExecStart=/usr/bin/node dist/server.js
Restart=on-failure
RestartSec=5
NoNewPrivileges=true

[Install]
WantedBy=multi-user.target
Systemd service unit running "/usr/bin/node dist/server.js" under user "www-data" with Restart=on-failure.
Flag-by-Flag Breakdown
After=network-online.targetWaits until host networking is online before launching
User=www-dataRuns process with least privilege instead of root
Restart=on-failureAutomatically recovers process after crashes (delay 5s)
NoNewPrivileges=trueSecurity hardening preventing child privilege escalation

Knowing how to list linux services with systemctl is an indispensable skill for administering Linux servers, verifying deployments, and troubleshooting production incidents. Because systemd manages the lifecycle of all system daemons, background workers, and operating system targets, systemctl acts as the unified administrative control plane for querying what is running, what has failed, and what is configured to launch automatically on boot.

A common point of confusion for administrators transitioning to systemd is the distinction between runtime unit objects active in memory and static unit configuration files saved on disk. The command systemctl list-units queries the active runtime dependency graph currently maintained by PID 1, whereas systemctl list-unit-files scans physical storage paths to report the enablement state of every installed service.

By applying precise filtering switches—such as constraining queries by unit type, operational state (running, failed, inactive), or boot enablement status (enabled, disabled, masked)—you can effortlessly audit system posture, isolate degraded units, and automate configuration compliance across server fleets.

Advertisement
List Linux Services with systemctl: Status, Units, and States — syntax, flags, and practical terminal workflow diagram
List Linux Services with systemctl: Status, Units, and States — command syntax, key options, and production workflow reference.

What systemctl Does and When to Use It

At the architectural level, systemd evaluates services through a structured three-state lifecycle model: LOAD, ACTIVE, and SUB. The LOAD state indicates whether systemd successfully located, parsed, and loaded the unit file into memory (e.g. loaded, not-found, bad-setting, or error). The high-level ACTIVE state describes the operational status (active, reloading, inactive, failed, or activating). The lower-level SUB state provides unit-type-specific granularity (e.g. for a service unit: running, exited, dead, auto-restart, or failed).

When you invoke systemctl list-unit-files, systemd bypasses active memory states and reads unit files located across the priority search paths (/etc/systemd/system/, /run/systemd/system/, and /usr/lib/systemd/system/). It checks whether a symbolic link pointing to each unit file exists inside target dependency directories (such as multi-user.target.wants/). If a valid symlink exists, the state is reported as enabled; if no link exists, it is reported as disabled; and if the unit file is symlinked to /dev/null, it is reported as masked (preventing any manual or automatic activation).

Under the hood, systemctl gathers runtime telemetry or dispatches control signals by reading virtual filesystems mounted at /proc and /sys, or by communicating with PID 1 (systemd) over D-Bus. Using flags such as list-units, list-unit-files, --type=service, --state=<state> turns raw process and service tables into actionable diagnostics during incident response.

Availability and Installation Across Linux Distributions

The systemctl utility is packaged in systemd across mainstream Linux distributions. It is pre-installed on standard Ubuntu, Debian, RHEL, Rocky Linux, AlmaLinux, Fedora, and Arch Linux systems, while minimal container images may require manual installation:

Advertisement

Before running administrative tasks or automation scripts, verify whether systemctl is installed and inspect which binary path and version your shell resolves:

type -a systemctl
systemctl --version 2>/dev/null || man -f systemctl

# Illustrative output (reviewed against documentation)
systemctl is /usr/bin/systemctl
systemctl (systemd)
# Debian / Ubuntu
sudo apt-get update && sudo apt-get install -y systemd

# RHEL / Rocky / AlmaLinux / Fedora
sudo dnf install -y systemd

# Arch Linux
sudo pacman -S --noconfirm systemd

# Alpine Linux
sudo apk add --no-cache openrc

Command Syntax, Arguments, and Exit Status Codes

systemctl list-units --type=service [OPTIONS] | systemctl list-unit-files --type=service [OPTIONS]

The command provides two primary operational forms: systemctl list-units [PATTERN...] to inspect loaded in-memory units, and systemctl list-unit-files [PATTERN...] to inspect on-disk unit configuration files. If invoked without a subcommand, systemctl defaults to list-units.

To target services specifically, use --type=service; otherwise, systemd includes mount points, sockets, timers, slices, and device units in the listing. Combine this with --state=<state> to filter by condition (e.g. --state=running or --state=failed), --all (or -a) to display inactive and dead units that are normally hidden, and --no-pager / --no-legend to streamline output for terminal parsing and automated shell pipelines.

  • 0 — Command executed successfully; matching units or unit files were returned.
  • 1 — Operational failure, such as invalid flag arguments or D-Bus communication failure with PID 1.
  • 2 — No units matched the specified search pattern or filter condition.
  • 3 — One or more units queried are in an inactive or failed state (when tested with is-active or is-failed).

Important Options and Flags Reference

Option / FlagLong Form / ArgumentTechnical Behavior and Purpose
list-unitssystemctl subcommandLists unit objects currently loaded and tracked in memory by systemd PID 1.
list-unit-filessystemctl subcommandLists installed unit files on disk and their boot activation state (enabled/disabled/masked).
--type=service-t serviceFilters results strictly to .service units, excluding timers, sockets, mounts, and devices.
--state=<state>--state=<state>Filters units by load, active, or sub-state (e.g. running, failed, inactive, enabled).
--all-aShows all loaded units including inactive, dead, and unloaded units normally suppressed.
--failed--failedConvenience shortcut equivalent to --state=failed; lists all degraded or crashed units.
--no-pager--no-pagerOutputs results directly to standard output without piping into less or more.
--no-legend--no-legendSuppresses table header and footer summary lines for easy scripting with awk and grep.
--user--userQueries the calling user's systemd user manager instance rather than the system-wide manager.

The most critical operational choice is distinguishing between systemctl list-units --type=service and systemctl list-unit-files --type=service. Use list-units when you want to answer: 'What services are actively executing or failed right now?'. Use list-unit-files when you want to answer: 'What services are installed on this server and configured to boot automatically on startup?'.

Advertisement

For scripting and continuous integration checks, always combine --no-pager --no-legend. This eliminates interactive pager locks and strips decorative header text, allowing clean piping into awk '{print $1}' to iterate over service names.

When combining short flags on the command line, POSIX and GNU utilities allow clustering boolean flags behind a single hyphen, provided any option taking an argument appears last. In automated shell scripts, using long-form GNU options where portable makes self-documenting code that is easier to audit during peer review.

Practical Basic and Advanced Usage Examples

1. List All Currently Active and Running Linux Services

Display all systemd service units that are currently loaded and actively executing on the system.

systemctl list-units --type=service --state=running

# Illustrative output (reviewed against documentation)
UNIT                        LOAD   ACTIVE SUB     DESCRIPTION
chrony.service              loaded active running chrony, NTP client/server
containerd.service          loaded active running containerd container runtime
dbus.service                loaded active running D-Bus System Message Bus
nginx.service               loaded active running A high performance web server
ssh.service                 loaded active running OpenBSD Secure Shell server
systemd-journald.service    loaded active running Journal Service

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state (i.e. generalization of SUB).
SUB    = The low-level unit activation state, values depend on unit type.
6 loaded units listed.

Filters strictly for running services, displaying the unit name, load state, active status, sub-state, and human description.

2. List All Failed or Degraded Services on the System

Instantly identify crashed or failed services requiring immediate administrative attention using --failed.

systemctl list-units --type=service --state=failed

# Illustrative output (reviewed against documentation)
UNIT             LOAD   ACTIVE SUB    DESCRIPTION
postgresql.service loaded failed failed PostgreSQL RDBMS Server

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state (i.e. generalization of SUB).
SUB    = The low-level unit activation state, values depend on unit type.
1 loaded units listed.

Reveals that postgresql.service entered a failed state, directing the administrator to investigate journalctl -u postgresql.service.

3. List All Installed Services and Their Boot Enablement Status

Scan physical disk paths to check whether services are enabled, disabled, or masked on system boot.

systemctl list-unit-files --type=service

# Illustrative output (reviewed against documentation)
UNIT FILE                              STATE           PRESET
chrony.service                         enabled         enabled
cron.service                           enabled         enabled
nginx.service                          enabled         enabled
postfix.service                        disabled        disabled
redis-server.service                   disabled        disabled
shellinabox.service                    masked          enabled

6 unit files listed.

list-unit-files shows on-disk configuration: nginx is enabled (starts on boot), redis is disabled, and shellinabox is masked.

4. List Only Enabled Services Configured to Start at Boot

Filter the unit files list to display only services configured to launch automatically on system boot.

systemctl list-unit-files --type=service --state=enabled

# Illustrative output (reviewed against documentation)
UNIT FILE                  STATE   PRESET
apparmor.service           enabled enabled
chrony.service             enabled enabled
containerd.service         enabled enabled
docker.service             enabled enabled
ssh.service                enabled enabled
systemd-resolved.service   enabled enabled

6 unit files listed.

Filters unit files by state=enabled to audit the server startup surface and verify that only expected daemons launch at boot.

5. Script-Friendly Clean Output Without Headers or Pager

Combine --no-legend and --no-pager to extract a raw list of running service names for bash automation.

systemctl list-units --type=service --state=running --no-legend --no-pager | awk '{print $1}'

# Illustrative output (reviewed against documentation)
chrony.service
containerd.service
dbus.service
nginx.service
ssh.service
systemd-journald.service

By suppressing headers and footers, the output can be piped directly into shell arrays or monitoring scripts.

6. List User-Level Services for the Current Shell Session

Pass the --user switch to inspect user-level systemd service units running under the current login session.

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

# Illustrative output (reviewed against documentation)
UNIT                      LOAD   ACTIVE SUB     DESCRIPTION
dbus.service              loaded active running D-Bus User Message Bus
pipewire.service          loaded active running PipeWire Multimedia Service
pulseaudio.service        loaded active running Sound Service

3 loaded units listed.

The --user flag interfaces with the per-user systemd instance (managing session daemons and desktop audio/video pipelines).

Real-World Workflows, Pipelines, and Shell Automation

Production Fleet Post-Deployment Health and Failed Service Audit

Execute a structured health check script following software deployments or package upgrades to detect failed units and capture diagnostic logs.

#!/usr/bin/env bash
set -euo pipefail

echo "=== 1. Checking overall system state ==="
SYSTEM_STATUS=$(systemctl is-system-running || true)
echo "Systemd overall state: ${SYSTEM_STATUS}"

echo "=== 2. Auditing failed services ==="
FAILED_UNITS=$(systemctl list-units --type=service --state=failed --no-legend --no-pager | awk '{print $1}')

if [ -z "${FAILED_UNITS}" ]; then
  echo "All services operating normally. Zero failed units detected."
else
  echo "[CRITICAL] Detected failed service units:"
  for UNIT in ${FAILED_UNITS}; do
    echo "--------------------------------------------------"
    echo "Unit: ${UNIT}"
    systemctl status "${UNIT}" --no-pager || true
    echo "Recent journal output for ${UNIT}:"
    journalctl -u "${UNIT}" -n 5 --no-pager || true
  done
  exit 1
fi

# Illustrative output (reviewed against documentation)
=== 1. Checking overall system state ===
Systemd overall state: degraded
=== 2. Auditing failed services ===
[CRITICAL] Detected failed service units:
--------------------------------------------------
Unit: redis-server.service
● redis-server.service - Advanced key-value store
     Loaded: loaded (/lib/systemd/system/redis-server.service; enabled)
     Active: failed (Result: exit-code) since Thu 2026-10-22 19:42:01 UTC
Recent journal output for redis-server.service:
Fatal error: Can't open the log file /var/log/redis/redis-server.log: Permission denied

This workflow audits systemd state, catches degraded nodes, and automatically pulls the root cause log lines from the systemd journal.

Inventorying Enabled Services for System Hardening and Attack Surface Reduction

Audit all enabled services to locate unnecessary listening daemons, disable them, and mask obsolete legacy services.

#!/usr/bin/env bash
set -euo pipefail

echo "=== 1. Auditing all boot-enabled services ==="
ENABLED_SERVICES=$(systemctl list-unit-files --type=service --state=enabled --no-legend --no-pager | awk '{print $1}')

echo "Total boot-enabled services: $(echo "${ENABLED_SERVICES}" | wc -l)"

# Identify risky or unnecessary network services
UNWANTED=("avahi-daemon.service" "cups.service" "bluetooth.service" "rpcbind.service")

for SVC in "${UNWANTED[@]}"; do
  if echo "${ENABLED_SERVICES}" | grep -q "^${SVC}$"; then
    echo "[HARDENING] Disabling and masking unwanted service: ${SVC}"
    sudo systemctl stop "${SVC}" 2>/dev/null || true
    sudo systemctl disable "${SVC}" 2>/dev/null || true
    sudo systemctl mask "${SVC}" 2>/dev/null || true
  fi
done

# Illustrative output (reviewed against documentation)
=== 1. Auditing all boot-enabled services ===
Total boot-enabled services: 24
[HARDENING] Disabling and masking unwanted service: avahi-daemon.service
Created symlink /etc/systemd/system/avahi-daemon.service → /dev/null.

Masking unwanted services creates a symlink to /dev/null, ensuring services like Avahi or CUPS cannot be accidentally started.

Pipelines, Redirection, Quoting, and Shell Expansion

When embedding systemctl inside shell pipelines (|), conditional chains (&& and ||), or command substitutions ($(...)), the calling shell performs tilde expansion, variable interpolation, and globbing before invoking the binary. Always wrap paths, patterns, and variables in quotes so whitespace and wildcard characters (*, ?) are not expanded prematurely, and use set -euo pipefail in unattended scripts.

Permissions, Security Implications, and Safe Execution

Running systemctl list-units and systemctl list-unit-files does not require root or sudo privileges; any local or remote user can inspect loaded services and boot configuration. However, modifying service states (such as start, stop, enable, disable, or mask) is restricted by PolicyKit (polkit) rules and requires root credentials.

Auditing service listings is a primary security hygiene practice for detecting unauthorized persistence mechanisms. Threat actors and malicious scripts frequently establish persistence by dropping custom .service files into /etc/systemd/system/ or ~/.config/systemd/user/. Regularly auditing systemctl list-unit-files --state=enabled helps identify anomalous or unfamiliar service units.

GNU/Linux, BSD, and BusyBox Implementation Differences

systemctl commands are standardized across all systemd-based Linux distributions (Ubuntu, Debian, RHEL, CentOS, Rocky Linux, AlmaLinux, Fedora, Arch Linux, openSUSE).

On non-systemd distributions, equivalent service inspection commands differ: Alpine Linux (OpenRC) uses rc-status (for running services) and rc-update show (for enabled runlevels); legacy SysVinit uses service --status-all or chkconfig --list; and FreeBSD uses service -e.

Troubleshooting Common Errors and Diagnostics

Output is truncated or wraps awkwardly off the screen

Root Cause: systemctl automatically pipes output into less with line wrapping enabled, cutting long descriptions off at terminal boundaries.

Resolution: Pass --no-pager to dump raw text directly to terminal, or pass the -l (--full) flag to prevent description truncation.

systemctl list-units --type=service --no-pager -l

A service is reported as 'disabled' but is actively running

Root Cause: The service was started manually or activated on-demand via a socket or another service dependency (Wants/Requires), even though its boot symlink is absent.

Resolution: This is normal systemd behavior; run systemctl status <service> to inspect what triggered its activation.

systemctl status <service_name>

Failed services continue to appear in list-units --state=failed after fixing

Root Cause: systemd retains failed unit markers in memory for administrative auditing until explicitly cleared.

Resolution: Run sudo systemctl reset-failed to clear the failed unit cache.

sudo systemctl reset-failed <service_name>
# Or clear all failed markers:
sudo systemctl reset-failed

Authoritative References and Official Documentation

Frequently Asked Questions

Quick answers to common questions and configurations

4 FAQs
list-units displays runtime unit objects currently loaded in systemd's memory (showing whether they are actively running or failed). list-unit-files lists the physical service files installed on disk and shows whether they are configured to start at boot (enabled, disabled, or masked).
A masked service is symlinked to /dev/null, rendering it completely unstartable. Neither administrators nor other dependent services can start it, even manually, until it is explicitly unmasked using systemctl unmask.
Run systemctl --failed --type=service or systemctl list-units --type=service --state=failed. This isolates crashed or degraded services immediately.
Use systemctl is-active --quiet <service_name>. It returns an exit code of 0 if the service is active and running, or non-zero if inactive or failed.
RR
Written byVerified Author

Rajesh Ray

I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.

SPAM-FREE MODERATED DISCOURSE

Join the Conversation & Perspective

Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.

AT
MP
JV
+2

No comments on this guide yet. Be the first to share your thoughts or ask a question!

Recommended Reading10 Guides

Related Technical Guides

Tested runbooks, server administration walkthroughs, and troubleshooting guides

Featured Infrastructure PartnerUp to 75% OFF + 3 Months Free

Supercharge Your Linux & Cloud Workloads with Hostinger

Deploy high-speed NVMe KVM VPS, Docker containers, and LiteSpeed-accelerated WordPress servers in under 60 seconds with full root access, dedicated IPv4, and 24/7 technical support.

Pure NVMe SSD StorageFull Root Access & SSHFree Domain & Unlimited SSL99.9% Uptime SLA
Plans from$2.99/mo
Claim Hostinger DealAffiliate link • Special discount applied at checkout