How to Get the List of Services on Linux

Table of Contents

As a system administrator, you are probably dealing with a lot of services every day. On Linux, services are used for many different purposes.

In this post, you will learn how you to list all services on your Linux machine.

List Services using systemctl

The easiest way to list services on Linux, when you are on a systemd system, is to use the systemctl command followed by list-units. You can specify the option in order to restrict the results to services only.

systemctl list-units --type=service --all
[root@ct7 ~]# systemctl list-units --type=service --all
  UNIT                                                  LOAD      ACTIVE   SUB     DESCRIPTION
  auditd.service                                        loaded    active   running Security Auditing Service
  chronyd.service                                       loaded    active   running NTP client/server
● cloud-init-local.service                              not-found inactive dead    cloud-init-local.service
  cpupower.service                                      loaded    inactive dead    Configure CPU power related settings
  crond.service                                         loaded    active   running Command Scheduler
  dbus.service                                          loaded    active   running D-Bus System Message Bus
● display-manager.service                               not-found inactive dead    display-manager.service
  dm-event.service                                      loaded    inactive dead    Device-mapper event daemon
  dracut-cmdline.service                                loaded    inactive dead    dracut cmdline hook
  ...
  ...
  NetworkManager.service                                loaded    active   running Network Manager
● ntpd.service                                          not-found inactive dead    ntpd.service
● ntpdate.service                                       not-found inactive dead    ntpdate.service
  plymouth-quit-wait.service                            loaded    inactive dead    Wait for Plymouth Boot Screen to Quit
  plymouth-quit.service                                 loaded    inactive dead    Terminate Plymouth Boot Screen
  plymouth-read-write.service                           loaded    inactive dead    Tell Plymouth To Write Out Runtime Data
  plymouth-start.service                                loaded    inactive dead    Show Plymouth Boot Screen
lines 1-47

List Services by State

In some cases, you may only be interested in services that have failed. For that, you can specify the state that you are looking for as an option of the systemctl command.

###Services in single state
systemctl list-units --state=<state>

###Services in multiple states
systemctl list-units --state=<state1>,<state2>

Where the state can be one of the following values: active, inactive, activating, deactivating, failed, not-found or dead.

For example, if we are only interested in active services, we are going to run the following command:

systemctl list-units --state=active
# systemctl list-units --state=active
boot.mount                                loaded active mounted   /boot
dev-hugepages.mount                       loaded active mounted   Huge Pages File System
dev-mqueue.mount                          loaded active mounted   POSIX Message Queue File System
home.mount                                loaded active mounted   /home
run-user-0.mount                          loaded active mounted   /run/user/0
sys-fs-fuse-connections.mount             loaded active mounted   FUSE Control File System
sys-kernel-config.mount                   loaded active mounted   Configuration File System
sys-kernel-debug.mount                    loaded active mounted   Debug File System
session-1.scope                           loaded active running   Session 1 of user root
auditd.service                            loaded active running   Security Auditing Service
chronyd.service                           loaded active running   NTP client/server
crond.service                             loaded active running   Command Scheduler
dbus.service                              loaded active running   D-Bus System Message Bus
...

List All Service Files using list-unit-files

Finally, if you are interested in loaded, installed, disabled as well as enabled service files, there is another command that might be pretty handy.

# systemctl list-unit-files --type=service
UNIT FILE                                     STATE
auditd.service                                enabled
[email protected]                               enabled
blk-availability.service                      disabled
brandbot.service                              static
[email protected]                        static
chrony-wait.service                           disabled
chronyd.service                               enabled
console-getty.service                         disabled
console-shell.service                         disabled
[email protected]                      static
cpupower.service                              disabled
crond.service                                 enabled
dbus-org.fedoraproject.FirewallD1.service     enabled
dbus-org.freedesktop.hostname1.service        static
dbus-org.freedesktop.import1.service          static

Conclusion

In this tutorial, you learnt how you can easily list services on a Linux system.

Leave a Comment

Required fields are marked *