Linux systems provide a variety of system services (such as process management, login, syslog, cron, etc.) and network services (such as remote login, e-mail, printers, web hosting, data storage, file transfer, domain name resolution (using DNS), dynamic IP address assignment (using DHCP), and much more).
Technically, a service is a process or group of processes (commonly known as daemons) running continuously in the background, waiting for requests to come in (especially from clients).
Linux supports different ways to manage (start, stop, restart, enable auto-start at system boot, etc.) services, typically through a process or service manager. Most if not all modern Linux distributions now use the same process manager: systemd.
What is Systemd?
Systemd is a system and service manager for Linux; a drop-in replacement for the init process, which is compatible with SysV and LSB init scripts, and the systemctl command is the primary tool to manage systemd.
Why List Running Services in Linux?
Knowing which services are running on your Linux system is important for:
- Monitoring resource utilization
- Troubleshooting performance issues
- Ensuring critical services are active
- Optimizing system performance and security
Systemd simplifies service management with powerful systemctl commands (which is also known as essential commands), making it easy to list, monitor, and manage active services.
In this guide, we will demonstrate the process of listing all running services under Systemd in Linux, providing a comprehensive walkthrough for users of all experience levels.
Listing Running Services Under SystemD in Linux
When you run the systemctl command without any arguments, it will display a list of all loaded systemd units (read the systemd documentation for more information about systemd units) including services, showing their status (whether active or not).
# systemctl

List All Loaded Services in Linux
To list all loaded services on your system (whether active; running, exited, or failed, use the list-units subcommand and --type
switch with a value of service.
# systemctl list-units --type=service OR # systemctl --type=service

List Only Active Services in Linux
And to list all loaded but active services, both running and those that have exited, you can add the --state
option with a value of active, as follows.
# systemctl list-units --type=service --state=active OR # systemctl --type=service --state=active

List Running Services in Linux Using systemctl
But to get a quick glance at all running services (i.e. all loaded and actively running services), run the following command.
# systemctl list-units --type=service --state=running OR # systemctl --type=service --state=running

Let’s explore the key terms related to Systemd units and their status:
- Unit – A unit could be a service, a socket, a device, or various other entities.
- Load – It indicates whether the unit is loaded or not. A unit can be loaded but not necessarily active.
- Active – It shows whether the unit is actively running or whether it has encountered issues and is in a failed or inactive state.
- SUB – It provides additional details about the specific state of the unit. For services, it might indicate whether the service is running (running), stopped (exited), or encountering issues (failed).
- Description – It helps users identify and understand the purpose of the unit without delving into the detailed configuration files.
Creating an Alias for systemctl Commands
If you frequently use the previous command, you can create an alias command in your ~/.bashrc file as shown, to easily invoke it.
# vim ~/.bashrc
Then add the following line under the list of aliases as shown in the screenshot.
alias running_services='systemctl list-units --type=service --state=running'

Save the changes in the file and close it. From now onwards, use the “running_services” command to view a list of all loaded, actively running services on your server.
# running_services #use the Tab completion

Find Which Port a Service is Using
Besides, an important aspect of services is the port they use. To determine the port a daemon process is listening on, you can use the netstat or ss command as shown.
Where the flag -l
means print all listening sockets, -t
displays all TCP connections, -u
shows all UDP connections, -n
means print numeric port numbers (instead of application names) and -p
means show the application name.
netstat -ltup | grep zabbix_agentd OR ss -ltup | grep zabbix_agentd
The fifth column shows the socket: Local Address:Port. In this case, the process zabbix_agentd is listening on port 10050.

Listing Open Firewall Services and Ports
Also, if your server has a firewall service running, which controls how to block or allow traffic to or from selected services or ports, you can list services or ports that have been opened in the firewall, using the firewall-cmd or ufw command (depending on the Linux distributions you are using) as shown.
firewall-cmd --list-services [FirewallD] firewall-cmd --list-ports sudo ufw status [UFW Firewall]

Automating Service Monitoring in Linux
Manually checking running services can be tedious, especially on production servers. Automating this process ensures you are always aware of service status changes without needing to check manually.
Check Running Services Every 5 Minutes with a Cron Job
A cron job is a scheduled task in Linux that runs at a specific interval. You can use it to log running services periodically and review them later in case of failures or unexpected shutdowns.
crontab -e
Add this line to log running services every 5 minutes.
*/5 * * * * systemctl list-units --type=service --state=running > /tmp/running_services.log
The output will be saved in /tmp/running_services.log
file and you can check the latest recorded services using:
cat /tmp/running_services.log OR tail -f /tmp/running_services.log
Restart a Service if It Fails
By default, if a service crashes or stops unexpectedly, it does not restart automatically unless explicitly configured. To ensure a service restarts whenever it fails, you can modify its systemd service unit file.
For example, use the following command to edit the service configuration (replace apache2
with the actual service name you want to restart automatically):
systemctl edit apache2
Once inside the editor, add the following lines.
[Service] Restart=always RestartSec=5s
Now, reload systemd to apply the changes.
systemctl daemon-reload
Then restart the service to ensure it picks up the new settings
systemctl restart apache2
To confirm that the systemd is set to restart the service automatically.
systemctl show apache2 --property=Restart
Conclusion
That’s all for now! In this guide, we demonstrated how to view running services under systemd in Linux. We also covered how to check the port service is listening on and how to view services or ports opened in the system firewall.
Do you have any additions to make or questions? If yes, reach us using the comment form below.