The command systemctl list-units provides a concise overview of active services, displaying one line per service. Here’s how to use it with pattern filtering:
# systemctl list-units sp*
UNIT LOAD ACTIVE SUB DESCRIPTION
spark-history-server.service loaded active running LSB: Spark history-server
spark-master.service loaded active running LSB: Spark master
● spark-thriftserver.service loaded failed failed LSB: Spark thriftserver
● spark-worker.service loaded failed failed LSB: Spark worker
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.
4 loaded units listed. Pass --all to see loaded but inactive units, too.
Use --state=running,failed,exited to show just specific services:
# systemctl list-units --state=failed sp*
UNIT LOAD ACTIVE SUB DESCRIPTION
● spark-thriftserver.service loaded failed failed LSB: Spark thriftserver
● spark-worker.service loaded failed failed LSB: Spark worker
Note: systemctl list-units shows the services that are currently in memory.
From the manual:
list-units [PATTERN...]
List units that systemd currently has in memory. This
includes units that are either referenced directly or through
a dependency, units that are pinned by applications
programmatically, or units that were active in the past and
have failed. By default only units which are active, have
pending jobs, or have failed are shown; this can be changed
with option --all. If one or more PATTERNs are specified,
only units matching one of them are shown. The units that are
shown are additionally filtered by --type= and --state= if
those options are specified.
When you run systemctl list-units, it only shows units that are currently loaded into memory. If a service hasn't been started or is completely inactive (not loaded, not running, and not triggered), it won't appear in this list unless you explicitly query for it.
To see all available units, even those not currently in memory, you can use systemctl list-unit-files --type=service. Here's the output on my Ubuntu machine:
# systemctl list-unit-files --type=service
UNIT FILE STATE VENDOR PRESET
apparmor.service enabled enabled
apport-autoreport.service static -
apport-forward@.service static -
apport.service generated -
apt-daily-upgrade.service static -
apt-daily.service static -
apt-news.service static -
autovt@.service alias -
blk-availability.service enabled enabled
bolt.service static -
cloud-config.service enabled enabled
cloud-final.service enabled enabled
cloud-init-hotplugd.service static -
cloud-init-local.service enabled enabled
cloud-init.service enabled enabled
console-getty.service disabled disabled
console-setup.service enabled enabled
container-getty@.service static -
cron.service enabled enabled
cryptdisks-early.service masked enabled
cryptdisks.service masked enabled
dbus-org.freedesktop.hostname1.service alias -
dbus-org.freedesktop.locale1.service alias -
dbus-org.freedesktop.login1.service alias -
dbus-org.freedesktop.resolve1.service alias -
dbus-org.freedesktop.timedate1.service alias -
dbus-org.freedesktop.timesync1.service alias -
dbus.service static -
debug-shell.service disabled disabled
dm-event.service static -
dmesg.service enabled enabled
dpkg-db-backup.service static -
e2scrub@.service static -
e2scrub_all.service static -
e2scrub_fail@.service static -