
Learn through the super-clean Baeldung Pro experience:
>> Membership and Baeldung Pro.
No ads, dark-mode and 6 months free of IntelliJ Idea Ultimate to start with.
Last updated: January 23, 2025
A daemon is a program that runs in the background and performs system-related tasks in Linux. These tasks include handling network connections, handling system logs, or managing hardware. Monitoring and managing daemons helps ensure critical services are running and can help in troubleshooting system issues.
In this tutorial, we’ll discuss how to list all running daemons across different init systems. We’ll focus on the systemd, SysVinit, and OpenRc init systems.
Before we list the running daemons, let’s first determine which init system is running on our Linux distribution:
$ ps -p 1 -o comm=
systemd
The above output indicates our system uses systemd as the init system.
To clarify, an init system is responsible for booting the system and managing services or daemons. It ensures that daemons are started, stopped, or restarted based on system needs.
systemd is the default init system and service manager in most popular Linux distributions such as Ubuntu, Fedora, and Debian. It groups processes into units, which are specified by configuration files with various extensions like .service for services.
systemctl is a command-line utility used to manage and interact with the systemd init system.
To begin, let’s list all active daemons on our system:
$ systemctl list-units --type=service --state=running
UNIT LOAD ACTIVE SUB DESCRIPTION
accounts-daemon.service loaded active running Accounts Service
bluetooth.service loaded active running Bluetooth service
cups.service loaded active running CUPS Scheduler
...
Let’s understand the above output:
In this example, we list all currently active and running services. The list-units subcommand lists all systemd units. Next, we use the –type=service option to filter the output to only show services. Lastly, the –state=running option filters the output to only show services that are actively running.
Furthermore, we can focus on a specific service by filtering the output. For example, let’s display all services related to bluetooth:
$ systemctl list-units --type=service --state=running | grep bluetooth
bluetooth.service loaded active running Bluetooth service
Here, we use the grep command to filter the list of running services and display only those related to Bluetooth.
Additionally, we can list all services regardless of whether they’re running, exited, or failed:
$ systemctl list-units --type=service
UNIT LOAD ACTIVE SUB DESCRIPTION
accounts-daemon.service loaded active running Accounts Service
alsa-restore.service loaded active exited Save/Restore Sound Card State
apport.service loaded active exited LSB: automatic crash report generation
bluetooth.service loaded active running Bluetooth service
...
This command lists services in various states.
We can also get more details about a specific daemon:
$ systemctl status dbus
● dbus.service - D-Bus System Message Bus
Loaded: loaded (/lib/systemd/system/dbus.service; static)
Active: active (running) since Thu 2025-01-16 10:30:01 EAT; 40min ago
TriggeredBy: ● dbus.socket
Docs: man:dbus-daemon(1)
Main PID: 839 (dbus-daemon)
Tasks: 1 (limit: 4491)
...
Above, we display some information about the dbus service, such as its current state, memory, and CPU usage, as well as log entries related to the service.
SysVinit is an init system used in older Linux distributions such as CentOS 6 or Debian 7. It manages services using scripts located in the /etc/init.d/ directory. These scripts are used to start, stop, restart, or check the status of a service.
The service command enables us to interact with and manage services in SysVinit systems.
To list all daemons and their statuses, we use the service –status-all command:
$ service --status-all
[ + ] acpid
[ ? ] alsa-utils
[ - ] anacron
[ + ] avahi-daemon
[ + ] bluetooth
...
In the above command, –status-all lists the status of all services, both running and stopped. From the output, [ + ] indicates the service is running, [ – ] indicates the service has stopped, and [ ? ] indicates the service has an unknown status.
In addition to listing all services, we can also check the status of a specific service or daemon using the status action and the service name:
$ service acpid status
acpid is running.
The output indicates that the acpid service is running. We can use this approach to monitor specific services.
The /etc/init.d/ directory contains scripts that manage system services or daemons. Each file in this directory is a script that represents a specific service or daemon. These scripts interact with and control background processes on a SysVinit-based system.
To display all service scripts available on our system, let’s list the files in the /etc/init.d/ directory:
$ ls /etc/init.d/
acpid apparmor cron grub-common kmod procps spice-vdagent whoopsie
alsa-utils apport cups hwclock.sh lightdm pulseaudio-enable-autospawn udev x11-common
anacron avahi-daemon cups-browsed irqbalance openvpn rsync ufw
...
Here, we list all service scripts in the /etc/init.d/ directory, including those for services that may not be currently running.
To determine which service is running or not, we can check the status of each service using its script. For instance, let’s check the status of the cron service:
$ /etc/init.d/cron status
cron is running.
The above output indicates the cron service is currently active and running.
On the other hand, we can loop through the scripts in the /etc/init.d/ directory and check their status to identify all running services:
$ for service in /etc/init.d/*; do
$service status 2>/dev/null | grep -q 'running' && echo "$service is running";
done
/etc/init.d/acpid is running
/etc/init.d/acpid-fakekey is running
/etc/init.d/avahi-daemon is running
/etc/init.d/bluetooth is running
...
Let’s explain the above command:
Using this approach, we can determine which services are currently running.
OpenRc is a dependency-based init system that provides service management for Unix-like systems. It’s mainly used on Linux distributions like Alpine, Gentoo, and Artix. In addition, it organizes services into runlevels, which are different states or modes the system can run in.
rc-status is a command-line utility that displays the status of system services in OpenRc:
$ rc-status
Runlevel: default
dbus [ started ]
syslog-ng [ started ]
acpid [ started ]
gpm [ started ]
...
Dynamic Runlevel: hotplugged
Dynamic Runlevel: needed/wanted
hdparm [started]
alsasound [started]
...
In this example, we display the status of services on various runlevels. From the output, default, hotplugged, and needed/wanted represent the runlevels, while [ started ] indicates the service is currently active and running.
Furthermore, we can list the status of all services across all runlevels using the -a option:
$ rc-status -a
Runlevel: boot
modules [ started ]
hwclock [ started ]
...
Runlevel: default
dbus [ started ]
syslog-ng [ started ]
...
Runlevel: nonetwork
local [ started ]
...
The above command displays all services and their status across all runlevels.
In addition, we can check the status of a specific service using the rc-service command:
$ sudo rc-service modules status
* status: started
This output indicates the modules service is currently active and running.
In this article, we explored how to list all running daemons in the systemd, SysVinit, and OpenRc init systems. In systemd, we looked at the systemctl command. Next, in SysVinit, we discussed the service command and examined the /etc/init.d/ directory. Lastly, in OpenRc, we utilized the rc-status and rc-service commands.