Daemons are essential background processes that keep a Linux system running smoothly. They operate without direct user interaction, providing critical services. This guide explains how to list all running daemons in Linux, covering different init systems.
Daemons, Processes, and Init Systems
Before diving into the commands, here’s a brief overview of the core concepts:
- Daemon
- Process
- Init system
To effectively manage services (like starting or stopping a web server), understanding daemons and the init system is crucial. For system monitoring and troubleshooting, a grasp of processes is essential.
What is a Daemon?
A daemon is a background process that runs continuously, providing essential services without direct user interaction.
Examples of daemons include:
sshd
: Manages SSH connections.cron
: Schedules tasks.apache2
ornginx
: Serve web pages.
Daemons typically start during system boot and run until shutdown.
Fun fact: Daemon names often end with “d” (e.g.,
sshd
,crond
).
What is a Process?
A process is any program or task currently running on your system.
Types of Processes:
- Foreground Processes: Interact directly with the user (e.g., a web browser).
- Background Processes: Run without user interaction (e.g., a file download).
- Daemons: Special background processes providing system services.
You can list processes using commands like ps
or top
.
ps aux
To check a specific process’s PID (e.g., nano):
ps aux | grep nano
For example, when you open a terminal, a bash
process begins. Running ls
creates a new process to execute the command.
What is an Init System?
The init system is the first process that starts when a Linux system boots (PID 1). It manages all other processes and services.
The init system is responsible for:
- Starting and stopping system services (daemons).
- Managing dependencies between services.
- Handling system shutdown and reboot.
Common Init Systems:
- Systemd: Widely used in modern Linux distributions (e.g., Ubuntu, Fedora, Debian). Use
systemctl
andjournalctl
to manage. - SysVinit: An older init system used in traditional distributions. Use
service
and/etc/init.d/
to manage. - OpenRC: A modern, flexible, and lightweight init system, often used in Gentoo, Alpine Linux, and Artix Linux.
- Upstart: A transitional init system used in some older Ubuntu versions. The command to manage is
initctl
. It is now obsolete.
For example, during system boot, the init system starts essential daemons like sshd
and cron
.
The init system starts and manages daemons. Both daemons and regular programs are types of processes. Use tools like ps
to list processes, but init-specific commands (e.g., systemctl
) to manage daemons.
To check your init system, run:
ps --pid 1
Example Output:
PID TTY TIME CMD
1 ? 00:00:00 systemd
This indicates the system uses Systemd.
Summary Table
Term | Definition | Example |
---|---|---|
Daemon | A background process providing system services. | sshd , cron , apache2 . |
Process | Any running program or task on the system. | bash , ls , sshd . |
Init System | The first process that starts at boot and manages all other processes/services. | systemd , SysVinit , OpenRC , Upstart . |
Processes vs. Daemons
A process is any running program or task, while a daemon is a special type of process running in the background without user interaction.
Key differences:
Feature | Process | Daemon |
---|---|---|
Runs in background? | No (usually in foreground) | Yes |
Attached to terminal? | Yes (when launched by user) | No (detached from terminal) |
Example | firefox , nano , htop |
sshd , cron , systemd-journald |
Managed by | The user or system | Init system (systemd , SysVinit , OpenRC ) |
List All Running Daemons using Systemd
Systemd manages daemons through services. It’s the default init system in many modern Linux distros.
Step 1: Use the systemctl
command to list running services.
systemctl list-units --type=service --state=running
Step 2: Understand the command’s options.
systemctl
: Main command for managing services in Systemd.list-units
: Lists active system units.--type=service
: Filters the output to show only services.--state=running
: Shows only running services.
Example Output:
UNIT LOAD ACTIVE SUB DESCRIPTION
accounts-daemon.service loaded active running Accounts Service
avahi-daemon.service loaded active running Avahi mDNS/DNS-SD Stack
bluetooth.service loaded active running Bluetooth service
bolt.service loaded active running Thunderbolt system 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
[...]
View Running Daemons using OpenRC
OpenRC manages services using rc-status
. This is common in distributions such as Alpine Linux and Gentoo.
Step 1: Execute the rc-status
command.
rc-status
Example Output:
Runlevel: default
sshd [ started ]
crond [ started ]
Display All Running Daemons using SysVinit
SysVinit utilizes init scripts stored in /etc/init.d/
. This is found in older Linux distributions.
Step 1: Use the service
command with grep
to filter running services.
service --status-all | grep "+"
Step 2: Interpret the command.
service --status-all
: Lists all services and their statuses.grep "+"
: Filters out only running services (services with[ + ]
in the output).
Example Output:
[ + ] cron
[ + ] networking
[ - ] apache2
Here, cron
and networking
are running, while apache2
is stopped.
Cheatsheet for Listing Running Daemons in Linux
Init System | Command to List Running Daemons |
---|---|
Systemd | systemctl list-units --type=service --state=running |
SysVinit | service --status-all |
OpenRC | rc-status |
This guide clarified the concepts of processes, daemons, and init systems, highlighting the key differences between processes and daemons. We also explored how to list running daemons across different init systems, providing practical examples.