How to List Running Services in Linux (systemctl Command Examples)

Linux systems run a variety of system services (daemons) in the background — such as process management, cron jobs, logging, SSH, DNS, web servers, and more. As a system administrator, it is essential to know how to list running services in Linux to ensure that critical services are active, unnecessary ones are disabled, and your server remains optimized for performance and security.

In this guide, we’ll explore multiple methods to list and manage services in Linux using systemctl and related commands. We’ll also cover how to check open ports, monitor services automatically, and even secure them for better stability.

Why List Running Services in Linux?

When you list running services in Linux, you get real-time visibility into what your system is doing. This helps with:

  • Monitoring resource usage – Spot services that consume CPU, RAM, or bandwidth.

  • Troubleshooting – Identify if a service is down (e.g., Apache, MySQL, SSH).

  • Security – Detect unauthorized or unnecessary background processes.

  • Optimization – Disable unwanted daemons to improve boot time and efficiency.

By regularly running commands to list running services in Linux, you maintain visibility and control over your infrastructure.

Enabled vs Running Services in Linux

It’s important to understand the difference between enabled and running services:

  • Enabled Services – Configured to start automatically at boot.

  • Running Services – Currently active in memory.

For example, a service may be enabled but not running yet (like cron waiting to be triggered). This distinction helps in troubleshooting why a service expected to run isn’t currently active.

  • List enabled services:

systemctl list-unit-files --type=service --state=enabled

List running services:

systemctl list-units --type=service --state=running

How to List Running Services in Linux with systemctl

The systemctl command is the most reliable way to list running services in Linux on modern distributions.

1. List All Services

systemctl list-units --type=service

or simply:

systemctl --type=service

This shows all loaded services, including active, exited, or failed ones.

2. List Only Active Services

systemctl list-units --type=service --state=active

This includes both running and exited services.

3. List Only Running Services

To list running services in Linux directly:

systemctl list-units --type=service --state=running
Output includes details like UNIT, LOAD, ACTIVE, SUB, and a description.

4. Check Status of a Specific Service

systemctl status sshd

This shows if SSH is running, its PID, recent logs, and whether it starts at boot.

5. List Failed Services

systemctl --failed
This helps quickly identify services that stopped unexpectedly.

6. Create an Alias for Convenience

You can create a shortcut command in ~/.bashrc:

alias running_services='systemctl list-units --type=service --state=running'

Now, type running_services anytime you need to list running services in Linux.

Check Which Ports Services Are Using

Services typically bind to ports (e.g., web server → port 80/443, SSH → port 22). To see which port a service is listening on:

netstat -ltup | grep sshd

or using ss command:

ss -ltup | grep apache2

Listing Firewall Services and Ports

If you use a firewall (like firewalld or UFW), list allowed services and ports:

  • For FirewallD:

    firewall-cmd --list-services firewall-cmd --list-ports
  • For UFW:
sudo ufw status
Regularly pairing firewall checks with the command to list running services in Linux makes your system more secure.

Automating Service Monitoring in Linux

Manually checking services can be tedious. Instead, automate it:

Using Cron Job to Log Running Services

crontab -e

Add:

*/5 * * * * systemctl list-units --type=service --state=running > /tmp/running_services.log

This logs running services every 5 minutes into /tmp/running_services.log.

Automatically Restart Failed Services

Edit a service configuration:

systemctl edit apache2

Add:

[Service] Restart=always RestartSec=5s

Reload systemd:

systemctl daemon-reload systemctl restart apache2
Now, if Apache fails, it will restart automatically.

Hardening Services with systemd

Beyond just being able to list running services in Linux, securing them is vital:

[Service]
NoNewPrivileges=true
ProtectSystem=full
PrivateTmp=true
These options reduce service privileges, isolate them, and limit file system access.

Summary

  • Use systemctl list-units --type=service --state=running to list running services in Linux.

  • Distinguish between enabled (start at boot) and running (currently active) services.

  • Check service ports with netstat or ss.

  • Monitor services automatically with cron jobs.

  • Restart failed services automatically with systemd directives.

  • Harden services using NoNewPrivileges, ProtectSystem, and PrivateTmp.

Conclusion

Learning how to list running services in Linux is a must-have skill for system administrators. With systemctl, you can manage, troubleshoot, and secure services effectively. Combine monitoring tools, firewall configurations, and automation to maintain a stable and secure Linux environment.

Frequently Asked Questions (FAQ)

Q1. How do I list all running services in Linux?
Run: systemctl list-units –type=service –state=running

Q2. How can I check if a service is enabled at boot?
systemctl list-unit-files –type=service –state=enabled

Q3. What is the difference between enabled and running services?
Enabled services start at boot, while running services are currently active.

Q4. How do I restart a failed service automatically?
Add Restart=always and RestartSec=5s in the service unit file.

Q5. How do I check which ports a service is using?
Use ss -ltup or netstat -ltup to see listening ports.

Share this:
WhatsApp Channel Join Now
Telegram Channel Join Now
Instagram Channel Join Now

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.