How to List All System Services in Debian 12 Bookworm
Categories:
4 minute read
Debian 12, codenamed “Bookworm,” is a robust and stable Linux distribution widely used in server and desktop environments. One of the key administrative tasks for system administrators is managing system services. Services, also known as “daemons,” run in the background and perform essential functions such as networking, security, and application management.
This article provides a comprehensive guide on how to list all system services in Debian 12 Bookworm. We will explore different methods using systemctl
, service
, and other relevant tools.
Understanding System Services in Debian 12
Before diving into listing services, it’s essential to understand how Debian 12 manages services. Like most modern Linux distributions, Debian 12 uses systemd as its default init system. Systemd is responsible for initializing and managing services, system processes, and dependencies.
Services in Debian 12 can have the following states:
- Active (running): The service is currently running.
- Inactive (dead): The service is not running.
- Failed: The service encountered an error.
- Enabled: The service is set to start automatically at boot.
- Disabled: The service is not set to start at boot.
Listing System Services Using systemctl
The primary command to list system services in Debian 12 is systemctl
. This command provides detailed information about services and their states.
1. List All Services (Active and Inactive)
To list all available services, whether running or stopped, use:
systemctl list-units --type=service --all
This command outputs a list of all systemd-managed services, along with their states.
2. List Only Active Services
If you want to see only running services, use:
systemctl list-units --type=service --state=running
This helps administrators quickly identify which services are currently operational.
3. List Failed Services
To find services that have encountered errors or failures:
systemctl list-units --type=service --state=failed
If a service has failed, you can check its status using:
systemctl status <service-name>
For example, to check the status of the Apache web server:
systemctl status apache2
4. List Enabled Services (Start at Boot)
To see which services are set to start automatically on boot, run:
systemctl list-unit-files --type=service | grep enabled
5. List Disabled Services (Not Started at Boot)
To check which services are disabled:
systemctl list-unit-files --type=service | grep disabled
Listing Services Using service
Command (SysVinit Compatibility)
Debian maintains compatibility with the older SysVinit system through the service
command. Although systemctl
is recommended, you can still use service
for basic service management.
1. List All Services
To see a list of all services recognized by service
, use:
service --status-all
This command will return a list of services, each prefixed with:
[ + ]
indicating the service is running.[ - ]
indicating the service is stopped.[ ? ]
indicating an unknown status (possibly not controlled byservice
).
2. Check the Status of a Specific Service
To check if a particular service is running, use:
service <service-name> status
For example:
service ssh status
Listing Services Using ls
in /etc/init.d/
Another way to list available services, particularly for legacy scripts, is by checking the /etc/init.d/
directory:
ls /etc/init.d/
This method is useful for finding services that might not be managed by systemd.
Using chkconfig
to List Services (Alternative Method)
The chkconfig
command is another tool that can be used to list services and their runlevel settings. However, it is not installed by default on Debian 12. You can install it using:
sudo apt install sysv-rc-conf
Then, list all services with:
sysv-rc-conf --list
Filtering and Searching for Specific Services
To search for a specific service, use grep
with systemctl
:
systemctl list-units --type=service --all | grep ssh
This helps quickly find if a specific service is running or exists on the system.
You can also use grep
with service
:
service --status-all | grep apache
Conclusion
Managing system services is a crucial skill for Debian administrators. Debian 12 Bookworm relies on systemd, making systemctl
the most powerful tool for listing and managing services. However, legacy commands like service
and /etc/init.d/
can still be useful in certain situations.
Summary of Key Commands
Command | Description |
---|---|
systemctl list-units --type=service --all | List all services |
systemctl list-units --type=service --state=running | List running services |
systemctl list-units --type=service --state=failed | List failed services |
`systemctl list-unit-files –type=service | grep enabled` |
service --status-all | List all services (SysVinit) |
ls /etc/init.d/ | List available init scripts |
sysv-rc-conf --list | List services with runlevels |
By understanding these commands, you can effectively monitor and manage services on your Debian 12 system, ensuring smooth and efficient operation.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.