How To List Running Services on Linux

In this guide, you are going to learn how to list running services on Linux System. After boot process in Linux System, it enters final system initialization,where it needs to start various services. A service, or daemon, is a program that performs a particular duty. init is the initialization daemon determines which services are started and in what order.

There are various initialization systems in Linux;

  • System V: A service manager based on the SysVinit standard controls which daemons and resources will be available by employing the concept of runlevels.
  • Systemd: systemd is a modern system and services manager with a compatibility layer for the SysV commands and runlevels. It has a concurrent structure, employs sockets and D-Bus for service activation, on-demand daemon execution, process monitoring with cgroups, snapshot support, system session recovery, mount point control and a dependency-based service control.
  • There was Upstart also. Upstart is an event-based replacement for the /sbin/init daemon which handles starting of tasks and services during boot, stopping them during shutdown and supervising them while the system is running.

Checking System Manager running on the System

In recent years most major Linux distributions have gradually adopted systemd as their default system manager while SysV and Upstart are not used by many major Linux distributions anymore.

Finding the location of the init using which command;

which init
/usr/sbin/init

The location of init program file is /usr/sbin directory. You can use readlink -f command with super user privileges to check if the program is linked to another program.

sudo readlink -f /usr/sbin/init
/usr/lib/systemd/systemd

According to the above output, you find that the init program file is linked to systemd.

Check init system using file command

To use file command to find the init system, simply run;

file /sbin/init
/sbin/init: symbolic link to /lib/systemd/systemd

Check init system with ps Utility

ps utility allows you to view processes. A process is a running program, we can use ps utility to determine the first (1) program loaded after the boot process.

ps -p 1
  PID TTY          TIME CMD
      1 ?        00:00:03 systemd

In the above output, the systemd program is running. Thus, the Linux system is using systemd.

Checking with pstree Utility

Another way to check the system manger is using pstree command, pipe (|) the command to head -n 4 command to display first four lines of pstree i.e

pstree | head -n 4
systemd-+-ModemManager---2*[{ModemManager}]
        |-NetworkManager---2*[{NetworkManager}]
        |-accounts-daemon---2*[{accounts-daemon}]
        |-acpid

As you can see in the above output, we obtain systemd meaning that the system manger is systemd. but if you obtain init, it means that the system is running SysVinit.

Listing Running Services on Systemd

The systemctl utility is the main gateway to managing systemd and system services.

Syntax;

systemctl [OPTIONS…] COMMAND [NAME…]

Exploring systemd is through the systemd units. A unit defines a service, a group of services, or an action. There are currently 12 main different systemd unit types:

  • automount
  • device
  • mount
  • path
  • scope
  • service
  • slice
  • snapshot
  • socket
  • swap
  • target
  • timer

Listing various loaded Units

Using systemctl command we can provide a list of the various units currently loaded in the Linux system.

systemctl list-units
 UNIT                                                                                        LOAD   ACTIVE SUB       DESCRIPTION                                      >
  proc-sys-fs-binfmt_misc.automount                                                           loaded active waiting   Arbitrary Executable File Formats File System Aut>
  sys-devices-pci0000:00-0000:00:02.0-drm-card0-card0\x2dLVDS\x2d1-intel_backlight.device     loaded active plugged   /sys/devices/pci0000:00/0000:00:02.0/drm/card0/ca>
  sys-devices-pci0000:00-0000:00:1a.0-usb1-1\x2d1-1\x2d1.2-1\x2d1.2:1.0-net-usb0.device       loaded active plugged   TECNO_CAMON_12                                   >
  sys-devices-pci0000:00-0000:00:1a.0-usb1-1\x2d1-1\x2d1.3-1\x2d1.3:1.0-bluetooth-hci0.device loaded active plugged   /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1>
  sys-devices-pci0000:00-0000:00:1b.0-sound-card0.device                                      loaded active plugged   7 Series/C216 Chipset Family High Definition Audi>
  sys-devices-pci0000:00-0000:00:1c.0-0000:01:00.0-net-enp1s0.device                          loaded active plugged   AR8162 Fast Ethernet                             >
  sys-devices-pci0000:00-0000:00:1c.1-0000:02:00.0-net-wlp2s0.device                          loaded active plugged   AR9285 Wireless Network Adapter (PCI-Express)    >
  sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda1.device    loaded active plugged   ST500LM012_HN-M500MBB 1                          >

Listing all loaded Services

Use the list-units command and --type switch with a value “service” to list all loaded services on your system. it will list all active services.

systemctl list-units --type=service
  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 active exited  Save/Restore Sound Card State                                                
  apache2.service                                     loaded active running The Apache HTTP Server                                                       
  apparmor.service                                    loaded active exited  Load AppArmor profiles                                                       
  apport.service                                      loaded active exited  LSB: automatic crash report generation                                       
  avahi-daemon.service                                loaded active running Avahi mDNS/DNS-SD Stack                                                      
  blk-availability.service                            loaded active exited  Availability of block devices                                                
  bluetooth.service                                   loaded active running Bluetooth service                                                            
  colord.service                                      loaded active running Manage, Install and Generate Color Profiles                                  
  console-setup.service                               loaded active exited  Set console font and keymap                                                  
  cron.service                                        loaded active running Regular background program processing daemon                                 
  cups-browsed.service                                loaded active running Make remote CUPS printers available locally                                  
  cups.service                                        loaded active running CUPS Scheduler

systemctl --type=service will produce the same output.

To see all loaded active and inactive units pass --all switch to systemctl list-units –type=service command i.e.

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    active   exited  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                                                                
  apache2.service                                     loaded    active   running The Apache HTTP Server                                                          
  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                                                   
● auditd.service                                      not-found inactive dead    auditd.service                                                                  
  auth-rpcgss-module.service                          loaded    inactive dead    Kernel Module supporting RPCSEC_GSS                                             
  avahi-daemon.service                                loaded    active   running Avahi mDNS/DNS-SD Stack                                                         
  blk-availability.service                            loaded    active   exited  Availability of block devices                                                   
  bluetooth.service                                   loaded    active   running Bluetooth service                                                               
  colord.service                                      loaded    active   running Manage, Install and Generate Color Profiles                                     
● connman.service                                     not-found inactive dead    connman.service                                                                 
● console-screen.service                              not-found inactive dead    console-screen.service                                                          
  console-setup.service                               loaded    active   exited  Set console font and keymap                                                     
  cron.service                                        loaded    active   running Regular background program processing daemon                                    
  cups-browsed.service                                loaded    active   running Make remote CUPS printers available locally                                     
  cups.service                                        loaded    active   running CUPS Scheduler                                                                  
  dbus.service                                        loaded    active   running D-Bus System Message Bus                                                        
  dm-event.service                                    loaded    inactive dead    Device-mapper event daemon                                                      
  dmesg.service                                       loaded    inactive dead    Save initial kernel messages after boot                                         
  e2scrub_all.service                                 loaded    inactive dead    Online ext4 Metadata Check for All Filesystems                                  
  e2scrub_reap.service                                loaded    inactive dead    Remove Stale Online ext4 Metadata Check Snapshots                               
  emergency.service                                   loaded    inactive dead    Emergency Shell                                                                 
● fcoe.service                                        not-found inactive dead    fcoe.service                                                                    
  fstrim.service                                      loaded    inactive dead    Discard unused blocks on filesystems from /etc/fstab

Listing all Services by State

To list services by state, use --state option with the value active, inactive, running, dead services in the system.

Active Services

Use the following command to obtain active service.

systemctl --type=service --state=active
  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 active exited  Save/Restore Sound Card State                                                
  apache2.service                                     loaded active running The Apache HTTP Server                                                       
  apparmor.service                                    loaded active exited  Load AppArmor profiles                                                       
  apport.service                                      loaded active exited  LSB: automatic crash report generation                                       
  avahi-daemon.service                                loaded active running Avahi mDNS/DNS-SD Stack                                                      
  blk-availability.service                            loaded active exited  Availability of block devices                                                
  bluetooth.service                                   loaded active running Bluetooth service                                                            
  colord.service                                      loaded active running Manage, Install and Generate Color Profiles                                  
  console-setup.service                               loaded active exited  Set console font and keymap                                                  
  cron.service                                        loaded active running Regular background program processing daemon                                 
  cups-browsed.service                                loaded active running Make remote CUPS printers available locally                                  
  cups.service                                        loaded active running CUPS Scheduler                                                               
  dbus.service                                        loaded active running D-Bus System Message Bus

Inactive Services

Use the following command to obtain inactive service.

systemctl --type=service --state=inactive
  UNIT                                   LOAD      ACTIVE   SUB  DESCRIPTION                                                                     
  alsa-state.service                     loaded    inactive dead Manage Sound Card State (restore and store)                                     
  anacron.service                        loaded    inactive dead Run anacron jobs                                                                
  apport-autoreport.service              loaded    inactive dead Process error reports when automatic reporting is enabled                       
  apt-daily-upgrade.service              loaded    inactive dead Daily apt upgrade and clean activities                                          
  apt-daily.service                      loaded    inactive dead Daily apt download activities                                                   
● auditd.service                         not-found inactive dead auditd.service                                                                  
  auth-rpcgss-module.service             loaded    inactive dead Kernel Module supporting RPCSEC_GSS                                             
● connman.service                        not-found inactive dead connman.service                                                                 
● console-screen.service                 not-found inactive dead console-screen.service                                                          
  dm-event.service                       loaded    inactive dead Device-mapper event daemon                                                      
  dmesg.service                          loaded    inactive dead Save initial kernel messages after boot                                         
  e2scrub_all.service                    loaded    inactive dead Online ext4 Metadata Check for All Filesystems                                  
  e2scrub_reap.service                   loaded    inactive dead Remove Stale Online ext4 Metadata Check Snapshots                               
  emergency.service                      loaded    inactive dead Emergency Shell                                                                 
● fcoe.service                           not-found inactive dead fcoe.service                                                                    
  fstrim.service                         loaded    inactive dead Discard unused blocks on filesystems from /etc/fstab                            
  fwupd-refresh.service                  loaded    inactive dead Refresh fwupd metadata and update motd                                          
  getty-static.service                   loaded    inactive dead getty on tty2-tty6 if dbus and logind are not available

Running Services

Use the following command to obtain running service.

systemctl --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                                               
  apache2.service             loaded active running The Apache HTTP Server                                          
  avahi-daemon.service        loaded active running Avahi mDNS/DNS-SD Stack                                         
  bluetooth.service           loaded active running Bluetooth service                                               
  colord.service              loaded active running Manage, Install and Generate Color Profiles                     
  cron.service                loaded active running Regular background program processing daemon                    
  cups-browsed.service        loaded active running Make remote CUPS printers available locally                     
  cups.service                loaded active running CUPS Scheduler                                                  
  dbus.service                loaded active running D-Bus System Message Bus                                        
  gdm.service                 loaded active running GNOME Display Manager                                           
  irqbalance.service          loaded active running irqbalance daemon                                               
  kerneloops.service          loaded active running Tool to automatically collect and submit kernel crash signatures
  libvirtd.service            loaded active running Virtualization daemon                                           
  ModemManager.service        loaded active running Modem Manager                                                   
  mysql.service               loaded active running MySQL Community Server                                          
  networkd-dispatcher.service loaded active running Dispatcher daemon for systemd-networkd                          
  NetworkManager.service      loaded active running Network Manager

Dead Services

Use the following command to obtain dead service.

systemctl --type=service --state=dead
  UNIT                                   LOAD      ACTIVE   SUB  DESCRIPTION                                                                     
  alsa-state.service                     loaded    inactive dead Manage Sound Card State (restore and store)                                     
  anacron.service                        loaded    inactive dead Run anacron jobs                                                                
  apport-autoreport.service              loaded    inactive dead Process error reports when automatic reporting is enabled                       
  apt-daily-upgrade.service              loaded    inactive dead Daily apt upgrade and clean activities                                          
  apt-daily.service                      loaded    inactive dead Daily apt download activities                                                   
● auditd.service                         not-found inactive dead auditd.service                                                                  
  auth-rpcgss-module.service             loaded    inactive dead Kernel Module supporting RPCSEC_GSS                                             
● connman.service                        not-found inactive dead connman.service                                                                 
● console-screen.service                 not-found inactive dead console-screen.service                                                          
  dm-event.service                       loaded    inactive dead Device-mapper event daemon                                                      
  dmesg.service                          loaded    inactive dead Save initial kernel messages after boot                                         
  e2scrub_all.service                    loaded    inactive dead Online ext4 Metadata Check for All Filesystems                                  
  e2scrub_reap.service                   loaded    inactive dead Remove Stale Online ext4 Metadata Check Snapshots                               
  emergency.service                      loaded    inactive dead Emergency Shell                                                                 
● fcoe.service                           not-found inactive dead fcoe.service

Listing Running Services on SysVinit

To view a SysVinit managed service’s status and control whether it is currently running, use the service utility.

Syntax;

service SCRIPT COMMAND [OPTIONS]

If you are using SysV system manager, to list all services in the system use service --status-all command i.e

service --status-all
[ + ]  acpid
 [ - ]  alsa-utils
 [ - ]  anacron
 [ - ]  apache-htcacheclean
 [ + ]  apache2
 [ + ]  apparmor
 [ + ]  apport
 [ + ]  avahi-daemon
 [ + ]  bluetooth
 [ - ]  console-setup.sh
 [ + ]  cron
 [ + ]  cups
 [ + ]  cups-browsed
 [ + ]  dbus

In the above output, the symbols means;

  • + : means that the service is running.
  • – : means that the service is not running at all.

Although some SysVinit commands have been modified to work with systemd utilities, others, such as service --status-all, might produce unpredictable or confusing results.

This marks the end of our guide on how list running services on Linux. Stay tuned for more guides. Hope this guide has been helpful.

You can also check;

Edit Text Files with Vim in Linux

Encrypt and Decrypt Files with Vim Editor

Compress and Uncompress Files with zip Command in Linux

Compress and Uncompress Files with tar Command in Linux

Reset Default Root Password on Request Tracker (RT)

Leave a Comment