Coming from a Windows environment, this question always seems to arise to newbies… How do you list running services in Linux? Well, systemd of course! One of the most common tasks when working with systemd is listing all available services and their status. This is useful for troubleshooting issues and understanding the services running on a system. In this article, we will explore how to list services with systemd using the systemctl
command. We will also cover how to list enabled and disabled services.
Listing All Services
Simple
First thing is first… The main command we will use throughout this exciting session will be systemctl. To list all services available on a Linux system using systemctl
, you can use the list-unit-files command with the --type=service
option. Here’s the command:
systemctl list-unit-files --type=service
systemd
the technical term for “services” is actually “units” (don’t ask why…). The output will look something like this:
UNIT FILE STATE
acpid.service enabled
apparmor.service disabled
auditd.service enabled
autovt@.service enabled
avahi-daemon.service enabled
bluetooth.service enabled
...
Notice that this variation of the command shows you the state of the systemd service.
Detailed
Okay, so what if you want a bit more detail about your services? Sure, we got a list but what the heck do they do?
Another way to list services with systemctl
is to use the list-units
command still using the --type=service
option. This command will display a list of all services that are currently running on the system, along with their status (active or inactive), the amount of time they have been running, and a brief description of the service! Here’s the command:
systemctl list-units --type=service
And this is what it should look like:
UNIT LOAD ACTIVE SUB DESCRIPTION
accounts-daemon.service loaded active running Accounts Service
apache2.service loaded active running The Apache HTTP Server
apparmor.service loaded active exited AppArmor initialization
apport.service loaded active exited LSB: automatic crash report generation
avahi-daemon.service loaded active running Avahi mDNS/DNS-SD Stack
...
Listing Enabled/Disabled Services
Enabled
This is where fun begins with more options!
In order to list only enabled services using systemctl, you can use the –state option with the value enabled. Here’s the command:
systemctl list-unit-files --type=service --state=enabled
Now, we get a list of all services that are enabled on the system, along with the state of the service. The output will look something like this:
UNIT FILE STATE
acpid.service enabled
auditd.service enabled
autovt@.service enabled
avahi-daemon.service enabled
bluetooth.service enabled
...
Disabled
--state=enabled
to --state=disabled
. Pretty obvious, no? Anyway, here’s the command:
systemctl list-unit-files --type=service --state=disabled
And this is what it should look like now!
UNIT FILE STATE
apache2.service disabled
apparmor.service disabled
atd.service disabled
avahi-dnsconfd.service disabled
console-setup.service disabled
...
It’s pretty dirt simple but there are tons of other ways you can play around with listing your services aka “units”. We could go over some more options later on… So, why not bookmark this page, come back later and maybe, maybe there will be more options…? Who knows…