How To Check Running Services In Linux : Linux Service Status And Management

Checking which services are currently running in Linux confirms that your web server or database is active. Knowing how to check running services in linux is a fundamental skill for any system administrator or developer. It helps you troubleshoot issues, monitor system health, and ensure critical applications are up and running. This guide walks you through every method, from simple commands to advanced tools, so you can quickly see what’s active on your machine.

Linux services are background processes that start automatically or on demand. They handle tasks like serving web pages, managing databases, or handling network connections. When something goes wrong—like your website being down—the first step is often checking if the service is running. Let’s dive into the most common ways to do this.

How To Check Running Services In Linux

The easiest way to see running services is with the systemctl command, if your system uses systemd. Most modern Linux distributions (like Ubuntu, CentOS, Fedora, and Debian) use systemd by default. Here’s how it works.

Using Systemctl To List Running Services

Open a terminal and type:

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

This shows all active services. The output includes the service name, load status, active state, and description. For example:

  • UNIT – The service name (e.g., nginx.service)
  • LOAD – Whether the unit was loaded
  • ACTIVE – If it’s running (active/running)
  • DESCRIPTION – What the service does

You can also filter by specific services. To check if Apache is running, use:

systemctl status apache2

Or for Nginx:

systemctl status nginx

The status output shows if the service is active, when it started, and recent log entries. This is the most direct method for checking services on systemd-based systems.

Checking Services With The Service Command

Older Linux distributions or those using SysV init rely on the service command. It works on many systems, even if systemd is present. To list all running services, run:

service --status-all

This shows all services with a plus sign (+) for running, a minus (-) for stopped, or a question mark (?) for unknown. For example:

  • [ + ] apache2 – Running
  • [ - ] mysql – Stopped
  • [ ? ] networking – Status unknown

To check a specific service, use:

service apache2 status

This command is simpler but less detailed than systemctl. It’s still usefull for quick checks on older systems.

Using Ps And Grep To Find Running Processes

Sometimes you need to see all processes, not just managed services. The ps command lists every running process on the system. Combine it with grep to filter for specific services.

List All Processes With Ps

Run:

ps aux

This shows a full list of processes, including user, PID, CPU usage, memory, and command. The output is long, so you can pipe it to grep to find a service. For example, to check if MySQL is running:

ps aux | grep mysql

If the service is active, you’ll see lines with “mysql” in them. The grep command itself also appears in the output, which is normal. To exclude it, use:

ps aux | grep mysql | grep -v grep

This method works on any Linux system, regardless of init system. It’s great for finding processes that aren’t managed as services, like custom scripts.

Using Pgrep For Simpler Filtering

The pgrep command is a shortcut for searching processes by name. It returns only the process IDs (PIDs). For example:

pgrep -a nginx

The -a flag shows the full command line. If the service is running, you’ll see its PID and command. If not, no output appears. This is faster than ps | grep and avoids the grep-in-output issue.

Using Top And Htop For Real-Time Monitoring

For a dynamic view of running processes, use top or htop. These tools update in real time and show resource usage.

Top Command Basics

Type top in the terminal. You’ll see a list of processes sorted by CPU usage by default. Look for your service name in the COMMAND column. Press q to exit. To filter by a specific service, press o and type the name (e.g., nginx). This highlights matching processes.

Top also shows system-wide information like load average, memory usage, and uptime. It’s usefull for identifying resource-hungry services.

Htop For A Better Interface

If htop is installed (install it with sudo apt install htop on Debian/Ubuntu or sudo yum install htop on CentOS), it provides a color-coded, scrollable interface. Run htop and use the arrow keys to navigate. You can search for a service by pressing F3 and typing the name. Htop also lets you kill processes easily.

Both tools are excellent for checking if a service is running and how much resources it’s using.

Using Netstat And Ss For Network Services

For services that listen on network ports (like web servers or databases), you can check if they’re running by looking at open ports.

Netstat Command

Run:

netstat -tulpn

This shows all listening ports. The -t flag for TCP, -u for UDP, -l for listening, -p for program name, and -n for numeric addresses. Look for your service’s port. For example, Apache uses port 80 or 443, MySQL uses 3306. If the port is listed, the service is running.

To filter for a specific port, use:

netstat -tulpn | grep :80

This shows if anything is listening on port 80.

Ss Command (Modern Replacement)

The ss command is faster and more modern than netstat. Use:

ss -tulpn

Output is similar. Look for the service name or port. For example, to check SSH:

ss -tulpn | grep ssh

Both commands are usefull for network services, but they won’t show non-network services like cron or systemd-journald.

Using Journalctl To Check Service Logs

Logs can tell you if a service is running or has failed. The journalctl command queries systemd’s journal.

Check Service Status With Journalctl

To see logs for a specific service, run:

journalctl -u nginx.service

This shows recent log entries. Look for messages like “Started nginx” or “Failed to start.” To see only the last few lines, add -n:

journalctl -u nginx.service -n 20

You can also follow logs in real time with -f:

journalctl -u nginx.service -f

This is usefull for debugging why a service stopped.

Using Init Scripts And Chkconfig For SysV Systems

If you’re on an older distribution without systemd, you might use init scripts directly. The chkconfig command lists services and their runlevels.

List Services With Chkconfig

Run:

chkconfig --list

This shows all services and whether they’re enabled at each runlevel. To check if a service is running, use the service command as described earlier. For example:

service httpd status

On SysV systems, init scripts are stored in /etc/init.d/. You can also run them directly:

/etc/init.d/apache2 status

This method is less common today but still appears on some enterprise systems.

Using Docker And Containerized Services

If you run services in Docker containers, checking them is different. Use docker ps to list running containers:

docker ps

This shows container IDs, names, images, and status. For example, if your web server runs in a container named “nginx-proxy,” you’ll see it here. To check logs:

docker logs nginx-proxy

For Kubernetes, use kubectl get pods to see running pods. This is essential for modern deployments.

Automating Service Checks With Scripts

You can write simple bash scripts to check services regularly. For example, a script to check if Apache is running and restart it if not:

#!/bin/bash
if systemctl is-active --quiet apache2; then
    echo "Apache is running"
else
    echo "Apache is down, restarting..."
    systemctl restart apache2
fi

Save this as check_apache.sh, make it executable with chmod +x check_apache.sh, and run it with cron for monitoring.

Common Issues And Troubleshooting

Sometimes services don’t show up as expected. Here are a few problems and solutions:

  • Service not found – The service might be named differently. Use systemctl list-units --type=service to see all available services.
  • Permission denied – Some commands require root. Use sudo before the command.
  • Service shows inactive – It might be disabled. Check with systemctl is-enabled servicename.
  • Process not in ps output – The service might have crashed. Check logs with journalctl.

Frequently Asked Questions

How do I check if a specific service is running in Linux?

Use systemctl status servicename for systemd systems, or service servicename status for SysV. You can also use ps aux | grep servicename to find the process.

What command shows all running services in Linux?

systemctl list-units --type=service --state=running lists all active services. For older systems, service --status-all shows all services with their status.

How can I check running services without systemd?

Use ps aux to see all processes, or service --status-all if the service command is available. The top or htop commands also work on any system.

Why is my service not showing as running even though it’s started?

The service might have failed silently. Check logs with journalctl -u servicename or look for error messages. Also verify the service name is correct.

Can I check running services remotely?

Yes, you can SSH into the remote machine and run the same commands. For multiple servers, consider tools like Ansible or Nagios for centralized monitoring.

Conclusion

Knowing how to check running services in linux is a daily task for anyone managing servers. Whether you use systemctl, ps, top, or netstat, each method gives you a different view of your system’s health. Start with systemctl for systemd systems, use ps for a quick process check, and turn to netstat for network services. With these tools, you can quickly diagnose issues and keep your services running smoothly. Practice these commands on your own machine to build confidence, and soon you’ll be able to spot problems before they affect users.