How To List Running Services In Linux : Active Daemon Process List

Active services currently running on your system can be listed with `systemctl list-units –state=running`. If you’ve ever wondered how to list running services in linux, you’re in the right place. This guide covers every major method, from systemd to init.d, with clear examples and practical tips. Whether you’re a beginner or a seasoned sysadmin, you’ll find exactly what you need.

Services are background processes that keep your Linux machine humming. They handle everything from web servers to database connections. Knowing which services are active helps you troubleshoot, optimize performance, and secure your system. Let’s dive into the most effective ways to list them.

How To List Running Services In Linux

Most modern Linux distributions use systemd as their init system. This means the `systemctl` command is your best friend. It’s fast, flexible, and gives you detailed control over services.

Using Systemctl To List Running Services

The simplest command is:

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

This shows all active services with their status. You’ll see columns like UNIT, LOAD, ACTIVE, SUB, and DESCRIPTION. The output is clean and easy to scan.

For a shorter version, use:

systemctl list-units --state=running

This lists all running units, not just services. It includes mounts, sockets, and timers. If you want only services, stick with the first command.

Understanding The Output

Each line shows a service unit. The ACTIVE column says “active” if it’s running. The SUB column might say “running” or “exited”. Pay attention to these details when troubleshooting.

You can also check a specific service:

systemctl status sshd

This gives you the service’s current state, recent logs, and process ID. It’s perfect for digging deeper.

Listing Services With Service Command

Older systems or those without systemd use the `service` command. It’s part of the sysvinit ecosystem. To see all running services:

service --status-all

This lists every service, with a plus sign (+) for running and a minus sign (-) for stopped. It’s less detailed than systemctl but works on many legacy systems.

To check a single service:

service apache2 status

This returns whether the service is active or not.

Using Init.d Scripts Directly

If your system uses System V init, you can list services by checking the /etc/init.d directory:

ls /etc/init.d/

This shows all available init scripts. To see which ones are running, you’ll need to check each one manually or use a script. It’s not as efficient as systemctl, but it’s good to know.

Checking Services With Ps And Grep

For a raw process-level view, combine `ps` with `grep`:

ps aux | grep -E "apache|nginx|sshd"

This lists all processes matching your service names. It’s not service-aware, but it shows you what’s actually executing. Use this when you suspect a service is running but not registered properly.

Using Netstat And Ss For Network Services

Network services like web servers or SSH daemons listen on specific ports. To list them:

ss -tlnp

This shows all TCP listening sockets with their associated processes. The `-p` flag reveals the process name and PID. It’s a quick way to see what’s serving connections.

For UDP services:

ss -ulnp

This is especially useful for DNS or DHCP services.

Listing Services With Top And Htop

Interactive tools like `top` or `htop` show running processes in real-time. Press `c` in top to see the command line, or use `htop` with its tree view to spot service processes. They’re not service-specific but give you a live snapshot.

Using Journalctl To See Service Logs

systemd logs everything to the journal. To list services that have recently logged:

journalctl --list-boots

This shows boot sessions. Then you can check services for a specific boot:

journalctl -b -0 --unit=sshd

This displays logs for the current boot. It’s helpful for verifying if a service started correctly.

Automating Service Listing With Scripts

You can write a simple bash script to list running services:

#!/bin/bash
systemctl list-units --type=service --state=running --no-pager

Save it as `list-services.sh`, make it executable with `chmod +x`, and run it anytime. This saves keystrokes if you check services often.

Common Pitfalls And How To Avoid Them

Sometimes a service appears running but isn’t actually functional. Always check the SUB column in systemctl output. “Running” means it’s active, but “exited” might mean it completed a task and stopped.

Another issue is permission. Some service commands require root. Use `sudo` if you get “permission denied” errors.

Also, remember that not all processes are services. Background tasks like cron jobs or user sessions aren’t listed by systemctl. Use `ps` for a complete picture.

Comparing Methods: Which One To Use?

For modern systems, `systemctl` is the gold standard. It’s fast, accurate, and integrates with logging. For legacy systems, `service –status-all` is your fallback. Use `ps` and `ss` when you need process-level details or network info.

If you’re writing scripts, stick with systemctl for consistency. It’s available on almost all recent distributions.

Real-World Example: Troubleshooting A Web Server

Imagine your website is down. First, list running services:

systemctl list-units --type=service --state=running | grep apache

If Apache isn’t listed, check its status:

systemctl status apache2

You might see “failed” or “inactive”. Then check logs:

journalctl -u apache2 -n 20

This shows the last 20 log lines. You’ll quickly spot configuration errors or port conflicts.

Listing Services On Different Distributions

Ubuntu and Debian use systemd by default. CentOS and RHEL also use systemd. Older versions of CentOS 6 use init.d. Alpine Linux uses OpenRC, which has its own commands:

rc-service --list

For OpenRC, you can check running services with:

rc-status

This shows all services and their runlevels. It’s a different approach but equally effective.

Using Systemctl With Filters

You can filter by service state more precisely:

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

This shows all active services, including those that are “exited” but still considered active. For strictly running services, use `–state=running`.

To list all services, including stopped ones:

systemctl list-units --type=service --all

This is useful for auditing what’s installed.

Checking Service Dependencies

Sometimes a service fails because a dependency isn’t running. Use:

systemctl list-dependencies sshd

This shows all units that sshd requires. You can then check each one’s status.

Using Systemctl With Pager

Long lists can be overwhelming. Use `–no-pager` to output everything at once, or pipe to `less`:

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

This lets you scroll through the output.

Listing Services By Load State

You can also see which services are loaded into memory:

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

This includes running and stopped services that are loaded. It’s a broader view.

Using Systemctl With Different Formats

For scripting, use `–output=json` to get machine-readable output:

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

This returns JSON, which you can parse with jq or Python.

Common Service Names To Know

Here are typical services you’ll encounter:

  • sshd – SSH daemon
  • apache2 or httpd – Web server
  • nginx – Web server
  • mysql or mariadb – Database
  • postgresql – Database
  • docker – Container engine
  • cron – Scheduled tasks
  • rsyslog – System logging

Knowing these helps you quickly identify what’s running.

Securing Your Services

Listing services is the first step. Next, disable unnecessary ones:

sudo systemctl disable bluetooth

This prevents it from starting at boot. Then stop it:

sudo systemctl stop bluetooth

Regularly audit your services to reduce attack surface.

Automating Service Monitoring

You can set up a cron job to log running services:

0 * * * * systemctl list-units --type=service --state=running --no-pager >> /var/log/services.log

This logs every hour. Review it for anomalies.

Troubleshooting Common Issues

If systemctl returns “Failed to get properties: Connection timed out”, your systemd might be hung. Try restarting it:

sudo systemctl daemon-reexec

If you see “Unit not found”, the service might not be installed. Check with `apt` or `yum`.

Sometimes a service shows “active (exited)” after running a one-time task. That’s normal for services like `systemd-tmpfiles-setup`.

Using Systemctl With Remote Systems

You can list services on remote machines using SSH:

ssh user@server "systemctl list-units --type=service --state=running"

This is useful for managing multiple servers.

Graphical Tools For Service Management

If you prefer a GUI, tools like Cockpit provide a web interface for systemd. Install it with:

sudo apt install cockpit

Then access it at https://your-server:9090. It shows running services, logs, and performance metrics.

Understanding Service States

systemd services have several states:

  • active (running) – Currently executing
  • active (exited) – Completed successfully
  • active (waiting) – Waiting for an event
  • inactive – Not running
  • failed – Encountered an error

Knowing these helps you interpret the output correctly.

Listing Services With Systemctl By Priority

You can sort services by their state or name:

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

This alphabetizes the list. Use `–sort=state` to group by state.

Using Systemctl With Timers

Timers are like cron jobs in systemd. List running timers:

systemctl list-timers

This shows when each timer will fire next. It’s related to services because timers trigger service units.

Checking Service Memory Usage

To see how much memory a service uses:

systemctl show sshd -p MemoryCurrent

This returns the current memory in bytes. Use this for capacity planning.

Listing Services With Systemctl By Unit File

You can see where a service’s unit file is located:

systemctl cat sshd

This shows the full unit file contents, including dependencies and execution commands.

Using Systemctl With Wildcards

List all services matching a pattern:

systemctl list-units "ssh*"

This shows all units starting with “ssh”. It’s handy for filtering.

Common Mistakes When Listing Services

One mistake is forgetting to use `sudo` for some commands. Another is misinterpreting “active (exited)” as a problem. Also, don’t confuse services with processes—services are managed units, while processes are raw execution.

Another error is assuming all services are in systemd. Some applications run as standalone processes. Always cross-check with `ps`.

Best Practices For Service Management

Document your services. Keep a list of what each one does. Disable unused services to free resources. Monitor service logs regularly. Use version control for unit files if you customize them.

Also, test service changes in a staging environment before applying to production.

Advanced: Writing Custom Service Units

If you create your own service, place the unit file in /etc/systemd/system/. Then enable and start it:

sudo systemctl enable myapp

sudo systemctl start myapp

You can then list it with the same commands.

Conclusion

Now you know multiple ways to list running services in Linux. Start with `systemctl list-units –state=running` for modern systems. Use `service –status-all` for legacy ones. Combine with `ps` and `ss` for deeper insights. Regular monitoring keeps your system healthy and secure. Practice these commands daily, and you’ll master service management in no time.

Frequently Asked Questions

How Do I List All Services Including Stopped Ones?

Use systemctl list-units --type=service --all. This shows every service unit, regardless of state.

What’s The Difference Between “Active” And “Running” In Systemctl?

“Active” means the service is started, but it might be in a substate like “exited” or “waiting”. “Running” specifically means the process is executing.

Can I List Services Without Systemctl?

Yes, on older systems use service --status-all or check /etc/init.d/. For process-level, use ps aux.

How Do I List Services On A Remote Server?

Use SSH: ssh user@server "systemctl list-units --type=service --state=running". Ensure you have SSH access.

Why Does Systemctl Show A Service As “Active (Exited)”?

This means the service ran a task and completed successfully. It’s normal for one-shot services like cleanup scripts.