How Can I Check Which Services Are Running in Linux?
In the world of Linux, understanding which services are running on your system is crucial for maintaining performance, security, and stability. Whether you’re a system administrator, developer, or an enthusiastic user, having a clear picture of active services can help you troubleshoot issues, optimize resource usage, and ensure that essential processes are functioning correctly. But with the vast array of tools and commands available, knowing where to start can sometimes feel overwhelming.
Checking running services in Linux isn’t just about curiosity—it’s a foundational skill that empowers you to take control of your system’s behavior. From background daemons to critical network services, each plays a role in the overall operation of your machine. Gaining insight into these processes allows you to make informed decisions about which services to enable, disable, or monitor more closely.
This article will guide you through the essentials of identifying active services on your Linux system. By exploring the common methods and commands used to list and manage these services, you’ll build a solid understanding that prepares you for more advanced system management tasks ahead. Whether you’re managing a personal computer or a production server, mastering this knowledge is a step toward greater confidence and control in the Linux environment.
Using systemctl to Check Running Services
The `systemctl` command is the primary tool for managing services on modern Linux distributions that use the systemd init system. To view which services are currently running, you can use `systemctl` with specific flags.
To list all active (running) services, the command is:
“`bash
systemctl list-units –type=service –state=running
“`
This command outputs a list of service units that are currently in the running state. The output includes the service name, load state, active state, and a brief description.
Key points about this command:
- `–type=service` filters the units to show only services.
- `–state=running` limits output to services actively running.
- It provides a real-time snapshot of the services systemd is currently managing.
You can also use `systemctl` to check the status of a specific service by running:
“`bash
systemctl status
“`
This provides detailed information including the service’s current state, recent logs, and whether it is enabled to start at boot.
Checking Services with service Command
On older Linux systems or those using SysV init scripts, the `service` command is commonly used to interact with system services. While not as feature-rich as `systemctl`, it remains useful for checking service status.
To see the status of a particular service, execute:
“`bash
service
“`
This returns whether the service is running, stopped, or in another state. However, it does not provide a consolidated list of all running services.
To get a list of all services and their status on SysV systems, you can examine the contents of `/etc/init.d/` and manually check each service, or use:
“`bash
service –status-all
“`
This command lists all services with symbols indicating their status:
- `[ + ]` means the service is running
- `[ – ]` means it is stopped
- `[ ? ]` means the status is unknown
Using ps and grep to Identify Running Service Processes
Another method to check running services is by inspecting processes directly. Since services run as processes, you can use `ps` combined with `grep` to find them.
For example:
“`bash
ps aux | grep
“`
This command searches the process list for any entries related to the specified service. It is helpful for verifying if a service’s daemon or process is active.
To list all system services by process name, common service names include:
- `sshd` for SSH daemon
- `httpd` or `apache2` for Apache web server
- `mysqld` for MySQL server
Using `ps` can be combined with `grep` and `awk` to script detailed checks.
Viewing Services with chkconfig and rc-status
On certain Linux distributions, especially older Red Hat-based or Gentoo systems, `chkconfig` and `rc-status` are used to manage and check services.
- `chkconfig –list` shows the runlevel settings and whether services are set to start at boot.
- `rc-status` provides a list of services and their current status in Gentoo systems.
These commands are useful in environments where systemd is not available.
Summary of Common Commands to Check Running Services
| Command | Purpose | Applicable Systems | Output Example |
|---|---|---|---|
systemctl list-units --type=service --state=running |
Lists all running systemd services | Modern Linux (systemd) | ssh.service loaded active running OpenSSH server daemon |
service --status-all |
Lists status of all SysV services | Older Linux distributions | [ + ] sshd [ – ] apache2 |
ps aux | grep <service-name> |
Checks running processes related to a service | All Linux systems | root 1234 0.0 0.1 123456 7890 ? Ss 10:00 0:00 sshd: user |
chkconfig --list |
Shows services and runlevel status | Older Red Hat-based systems | sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off |
rc-status |
Lists service status on Gentoo | Gentoo Linux | sshd [started] |
Methods to Identify Running Services in Linux
Determining which services are active on a Linux system is essential for system administration, troubleshooting, and security auditing. Linux distributions primarily utilize different init systems such as systemd, SysVinit, or Upstart, and the commands to check running services vary accordingly.
Using systemd-based Commands
Most modern Linux distributions including Ubuntu (from 15.04), CentOS 7+, Debian 8+, and Fedora use systemd as the init system. The systemctl utility provides a comprehensive interface to manage and query system services.
systemctl list-units --type=service --state=running: Lists all services currently active and running.systemctl status <service_name>: Displays detailed information about a specific service, including its status, logs, and dependencies.systemctl is-active <service_name>: Returns whether a service is active or not, useful for scripting.
| Command | Description | Example Output |
|---|---|---|
systemctl list-units --type=service --state=running |
Lists all running services |
ssh.service loaded active running OpenSSH server daemon
cron.service loaded active running Regular background program processing daemon
|
systemctl status ssh.service |
Shows detailed status of SSH service |
● ssh.service - OpenSSH server daemon
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2024-06-14 09:22:10 UTC; 3h ago
|
Using SysVinit Commands
Some older or specialized Linux distributions still use the traditional SysVinit system. In these cases, service management is done via scripts located in /etc/init.d/ or managed by the service command.
service --status-all: Lists all available services with their status indicated by symbols.service <service_name> status: Checks the status of a particular service.
The status symbols in service --status-all output are:
[ + ]: Service is running[ - ]: Service is stopped[ ? ]: Status unknown or unsupported
Using Upstart Commands
Some Ubuntu versions and other distributions use Upstart as their init system. Services can be checked using the initctl command.
initctl list: Lists all services and their statuses.initctl status <service_name>: Shows the status of a specific service.
Alternative Commands to Investigate Running Services and Processes
In addition to init system-specific tools, Linux offers several general-purpose commands that can help identify active services by inspecting processes and network ports.
ps aux | grep <service_name>: Searches for the service process in the running processes list.netstat -tulnporss -tulnp: Displays network sockets listening on TCP and UDP ports, often associated with running services.toporhtop: Interactive tools to monitor active processes in real-time.
Summary Table of Commands to Check Running Services
| Init System | Primary Command | Purpose |
|---|---|---|
| systemd | systemctl list-units --type=service --state=running |
List all running services |
| SysVinit | service --status-all |
List all services with status symbols |
| Upstart | initctl list |
List all services and statuses |
| General Process Check | ps aux | grep <service_name> |
Check if a specific service process is running |
| Network Socket Check | ss -tulnp |
List all listening ports and associated services |
