List Running Services with ps Command
In this article, we will see how to use the ps
command to list all running services on Linux. In Linux, a process is an instance of a running program. Each process has a unique Process ID (PID) and can be in various states such as running, sleeping, or stopped. Services, on the other hand, are background processes that perform specific tasks, often started at boot time and managed by the system’s init system (like systemd
or init
).
You can check more details about ps
command on the following link.
The ps
Command
The ps
(process status) command is used to display information about active processes. It provides a snapshot of the current processes, including details like PID, user, CPU usage, memory usage, and more.
Listing All Running Services
To list all running services using the ps
command, you can use various options and filters. Here are some common usages:
Basic Usage
ps -e
e
: Shows all processes.
This command lists all processes running on the system.
Detailed Information
ps -ef
e
: Shows all processes.f
: Displays full-format listing.
The -f
option provides a full-format listing, including additional details like the parent process ID (PPID) and the command that started the process.
Filtering by Service Name
ps -ef | grep <service_name>
Replace <service_name>
with the name of the service you want to filter. This command helps you find specific services.
Using ps
with aux
ps aux
a
: Shows processes for all users.u
: Displays the user-oriented format.x
: Shows processes not attached to a terminal.
The aux
options provide a detailed listing of all processes, including those not started by the current user.
Detailed Options
ps -A
orps -e
: Show all processes.ps -a
: Show all processes except session leaders and processes not associated with a terminal.ps -u [username]
: Show processes for a specific user.ps -p [pid]
: Show information for a specific process ID.ps --sort=[key]
: Sort the output based on the specified key (e.g., %cpu, %mem, pid).ps -o [format]
: Customize the output format. For example,ps -o pid,cmd
shows only the PID and command of each process.
Understanding the Output
When you run ps aux
, you typically see columns like:
- USER: The user who owns the process.
- PID: The process ID.
- %CPU: The percentage of CPU usage.
- %MEM: The percentage of memory usage.
- VSZ: Virtual memory size.
- RSS: Resident Set Size (the non-swapped physical memory that a task has used).
- TTY: The terminal associated with the process.
- STAT: The process state (e.g., S for sleeping, R for running).
- START: The start time of the process.
- TIME: The cumulative CPU time.
- COMMAND: The command that started the process.
Useful Examples
Listing All systemd
Services
systemd
is a popular init system used in many Linux distributions. To list all systemd
services, you can use:
ps -ef | grep systemd

This command will display all processes related to systemd
, helping you identify active services.
List all Processes Sorted by Memory Usage
The command lists all running processes on a Linux system and sorts them in descending order by memory usage. Let’s break it down:
ps aux --sort=-%mem
ps
: The process status command to view running processes.aux
:a
: Show processes for all users (not limited to the current session).u
: Display output in a user-oriented format, including user, CPU usage, memory usage, etc.x
: Show processes without a controlling terminal (e.g., daemon processes).
--sort=-%mem
:--sort
: A flag to sort the output.-%mem
: Specifies the sorting column, which is %mem (percentage of memory usage).- The
-
(negative) sign ensures the output is sorted in descending order. Without the-
, the processes would be listed in ascending order.
Display Specific Columns (PID, User, Command)
ps -eo pid,user,cmd
-e
: Select all processes.-o
: Format the output. You can specify the columns you want to display.
Show Processes of a Specific User
ps -u username
Output of this command:
PID TTY TIME CMD
2960 ? 00:00:00 systemd
2962 ? 00:00:00 (sd-pam)
3065 ? 00:00:00 sshd
3066 pts/0 00:00:00 bash
3159 pts/0 00:00:00 ps
Monitor the Memory Usage at Regular Intervals
watch -n 1 'ps aux --sort=-%mem | head -n 10'

Conclusion
The ps
command is a powerful tool for monitoring processes and services in a Linux system. Whether you’re diagnosing system performance issues, troubleshooting services, or managing running applications, ps
provides flexibility and control.
Key Features
- Display running processes with extensive details (PID, USER, CPU, MEMORY usage, COMMAND, and more).
- Format output with custom columns using the
-o
option. - Sort processes based on specific criteria like CPU or memory usage (
--sort
flag).
You can also check this possibility of Process Management