https://ostechnix.com/list-all-running-daemons-in-linux
How To List All Running Daemons In Linux
Find Running Daemons on Linux (Systemd, SysVinit, OpenRC)
A daemon is a background process that runs without direct user interaction. Linux systems use different init (initialization) systems to manage daemons. The common ones are Systemd, SysVinit, and OpenRC. In this tutorial, we will explain different ways to list all running daemons for each init system in Linux.
Understanding Daemons, Processes and Init Systems
Before getting into the topic, allow me to briefly explain the following key terminologies, as they are important for understanding the rest of the tutorial.
- Daemon,
- Process,
- Init system.
If you want to manage services (like starting or stopping a web server), you need to understand daemons and the init system.
If you want to monitor or troubleshoot your system, you need to understand processes.
1. What is a Daemon?
A daemon is a background process that runs continuously on a Linux system, usually without direct user interaction.
Daemons provide essential services to the system or other programs. For example:
sshd
manages SSH connections.cron
schedules tasks.apache2
serves web pages.
Daemons typically start when the system boots and keep running until the system shuts down.
Example:
If you’re using a web server, the apache2
or nginx
daemon runs in the background to handle web requests.
Fun fact: Daemon names often end in "d" (like
sshd
,crond
).
2. What is a Process?
A process is any program or task that is currently running on your system.
Types of Processes:
- Foreground Processes: These are started by the user and interact directly with the user (e.g., a web browser or text editor).
- Background Processes: These run without user interaction (e.g., a file download or system update).
- Daemons: A special type of background process that provides system services.
You can list all processes using commands like ps
or top
.
ps aux
You can the check a specific process's (E.g. nano) PID using command:
ps aux | grep nano
Example:
When you open a terminal, a bash
process starts. If you run a command like ls
, a new process is created to execute that command.
Related Read:
- How To Find Parent Process ID (PPID) In Linux: A Step-by-Step Guide
- How To Display Process Information Using Procs On Linux
- How To Find Out How Long A Process Has Been Running In Linux
- How To Change The Priority Of A Process In Linux
- How To Suspend A Process And Resume It Later In Linux
- Reptyr – Move A Running Process From One Terminal To Another Without Closing It
3. What is an Init System?
The init system is the first process that starts when a Linux system boots (with Process ID 1, or PID 1
). It manages all other processes and services on the system.
The init system is responsible for:
- Starting and stopping system services (daemons).
- Managing dependencies between services.
- Handling system shutdown and reboot.
Some of the Common Init Systems are:
- Systemd: The most widely used init system in modern Linux distributions (e.g., Ubuntu, Fedora, Debian). Commands to manage systemd are
systemctl
, andjournalctl
. - SysVinit: An older init system used in traditional Linux distributions. Commands to manage SysVinit are
service
,/etc/init.d/
. - 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. Command to manage is
initctl
. It is now obsolete, as most recent Ubuntu distributions have moved to systemd.
Example:
When you boot your system, the init system starts essential daemons like sshd
(for SSH) and cron
(for scheduled tasks).
The init system starts and manages daemons (background services). Both daemons and regular programs (like a web browser) are types of processes. You can list all processes using tools like ps
, but you need 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 means the system uses Systemd.
Summary Table
Term | Definition | Example |
---|---|---|
Daemon | A background process that provides 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
As I already noted, a process is any running program or task on your system (like a text editor, web browser, or background service).
A daemon is a special type of process that runs in the background without user interaction, usually providing system services (like handling network connections, logging, or scheduling tasks).
Here's the key differences between processes and daemons:
Feature | Process | Daemon |
---|---|---|
Runs in background? | No (usually runs 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 ) |
Alright. I hope you now have a good understanding of daemons, processes, and init systems. Now, let's learn how to list daemons for each init system.
First, let us start with Systemd.
1. List All Running Daemons using Systemd
Systemd uses services to manage daemons. Systemd is the default init system in many modern Linux distros like Arch Linux, Debian, Fedora, RHEL, and Ubuntu.
You can check running services with:
systemctl list-units --type=service --state=running
Explanation:
systemctl
→ The 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 currently 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 [...]
2. Display All Running Daemons using SysVinit
SysVinit uses init scripts stored in /etc/init.d/
. It is used in older versions of Linux distros such as Debian 7, CentOS 6.
To list running services:
service --status-all | grep "+"
Explanation:
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.
3. View Running Daemons using OpenRC
OpenRC manages services using rc-status in some linux distributions such as Alpine Linux, and Gentoo.
To list active daemons:
rc-status
Example Output:
Runlevel: default sshd [ started ] crond [ started ]
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 |
Conclusion
In this tutorial, we discussed the concepts of processes, daemons, and init systems, and the key differences between processes and daemons to clarify their roles in a Linux system.
We also covered how to list running daemons across different init systems, such as Systemd, SysVinit, and Upstart, along with practical examples.
We hope this guide has been helpful!
No comments:
Post a Comment