Home Linux How to List Linux Services using Systemctl

How to List Linux Services using Systemctl

by admin

Linux runs a multitude of services in the background, including network and system functions. Linux services are also referred to as daemons, which is the term for a collection of back-end processes. Various techniques and technologies can be used to list and manage services on a Linux system. A software package called Systemd is commonly used to administer Linux systems and is a replacement for the init process. Its primary goal is to standardise service behaviour and configuration across Linux distributions; A “system and service manager” is the main part of it.

Systemd provides control over all system Linux tasks. With the help of this tool, a process can be launched or stopped, and Systemd also allows for the listing of all enabled, running and disabled Linux services.

Like the init daemon, systemd is a daemon that oversees other daemons, which are background processes like systemd itself. Systemd is the final daemon to shut down during shutdown and is the first daemon to start up while booting. The first process (PID 1) has a specific role on Unix systems, as it substitutes the parent of a process when the original parent terminates. The systemd daemon serves as the root of the user space’s process tree. As a result, the first process is especially well suited for the task of daemon monitoring.

The systemctl command may be used to introspect and control the state of the “systemd” system and service manager. Let’s take a look at some examples of how the systemctl command can be used.

List All Linux Services Using systemctl

To list all the services on a Linux system that uses systemd, the following command can be used:

systemctl list-units --type=service --all
  UNIT                                           LOAD      ACTIVE   SUB     DESCRIPTION                                                   >
  accounts-daemon.service                        loaded    active   running Accounts Service                                              >
  acpid.service                                  loaded    active   running ACPI event daemon                                             >
  alsa-restore.service                           loaded    inactive dead    Save/Restore Sound Card State                                 >
  alsa-state.service                             loaded    inactive dead    Manage Sound Card State (restore and store)                   >
  anacron.service                                loaded    inactive dead    Run anacron jobs                                              >
  apparmor.service                               loaded    active   exited  Load AppArmor profiles                                        >
  apport-autoreport.service                      loaded    inactive dead    Process error reports when automatic reporting is enabled     >
  apport.service                                 loaded    active   exited  LSB: automatic crash report generation                        >
  apt-daily-upgrade.service                      loaded    inactive dead    Daily apt upgrade and clean activities                        >
  apt-daily.service                              loaded    inactive dead    Daily apt download activities                                 >
  atd.service                                    loaded    active   running Deferred execution scheduler                                  >
● auditd.service                                 not-found inactive dead    auditd.service                                                >
  avahi-daemon.service                           loaded    active   running Avahi mDNS/DNS-SD Stack                                       >
  blk-availability.service                       loaded    active   exited  Availability of block devices                                 >
  cloud-config.service                           loaded    active   exited  Apply the settings specified in cloud-config

The output lists the services and whether they are loaded and their current state.

List Loaded and Running Services

Rather than list all the services, we can filter the output to only list loaded services:

systemctl list-units --type=service
  UNIT                                           LOAD   ACTIVE SUB     DESCRIPTION                                                        >
  accounts-daemon.service                        loaded active running Accounts Service

Likewise, we can choose to only list running services:

systemctl list-units --type=service --state=running
  UNIT                                           LOAD   ACTIVE SUB     DESCRIPTION
  accounts-daemon.service                        loaded active running Accounts Service
  acpid.service                                  loaded active running ACPI event daemon
  atd.service                                    loaded active running Deferred execution scheduler
  avahi-daemon.service                           loaded active running Avahi mDNS/DNS-SD Stack

List Enabled and Disabled Services

Enabled services will start up when the Linux system starts up, whilst disabled services will not. You can check which services are enabled easily by using systemctl to list enabled services:

systemctl list-unit-files --state=enabled
UNIT FILE                                      STATE   VENDOR PRESET
snap-amazon\x2dssm\x2dagent-5163.mount         enabled enabled
snap-amazon\x2dssm\x2dagent-5656.mount         enabled enabled
snap-core-13308.mount                          enabled enabled

And to list the services that are not enabled:

systemctl list-unit-files --state=disabled
UNIT FILE                              STATE    VENDOR PRESET
proc-sys-fs-binfmt_misc.mount          disabled enabled
acpid.service                          disabled enabled
console-getty.service                  disabled disabled
debug-shell.service                    disabled disabled

Summary

This short tutorial demonstrates how to use the systemctl command to list Linux services, including how to list all services, loaded services and running services.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More