Introduction
Each application you use, or a command you run on your Linux system creates a process or task. A system administrator must manage processes effectively to ensure optimal system performance.
This tutorial covers different Linux commands to list running processes in Linux.
Prerequisites
- A system running Linux (this tutorial uses Ubuntu 22.04).
- An account with root or sudo privileges.
- Access to the terminal.
List Running Processes in Linux
A process in Linux starts every time you launch an application or run a command. While each command creates one process, applications create and run multiple processes for different tasks.
By default, each new process starts as a foreground process. This means it must finish before a new process begins. Running processes in the background allows you to perform other tasks simultaneously.
Note: Learn more about terminating Linux processes in our guide to killing processes in Linux.
To list currently running processes, use the ps
, top
, htop
, and atop
Linux commands. To identify individual processes, combine the ps
command with the pgrep
command
List Linux Processes Using ps Command
The Linux ps
command creates a snapshot of the currently running processes. Unlike the other commands on this list, ps
presents the output as a static list that is not updated in real time.
The ps
command uses the following syntax:
ps [options]
Frequently used ps command options include:
Option | Description |
---|---|
-a | Lists all processes except session leaders (instances where the process ID is the same as the session ID) and processes not associated with a terminal. |
-A, -e | Lists all processes on the system. |
-d | Lists all processes except session leaders. |
--deselect, -N | Displays processes that do not match the specified criteria. |
-f | Displays full-format listing. |
-j | Displays output in the jobs format. |
-t | Lists all processes associated with this terminal. |
-r | Lists only running processes. |
-u | Displays processes for a specific user. |
-x | Includes processes without controlling terminals. |
-p | Displays processes for a specific process ID (PID). |
-C | Displays processes based on command name. |
--sort | Sorts the processes based on specified criteria. |
a | Shows all processes for all users. |
u | Lists processes with detailed information. |
x | Includes processes without a controlling terminal. |
Note: Check the complete list of ps
command options using man ps
.
Run the ps
command without any options :
ps
The default output includes the following categories:
PID
. Process identification number.TTY
. The type of terminal the process is running on.TIME
. The total CPU usage.CMD
. The name of the command that started the process.
Using the combination of a
, u
, and x
options results in a more detailed output:
ps aux
The expanded output with new categories include:
USER
. The name of the user running the process.%CPU
. The CPU usage percentage.%MEM
. The memory usage percentage.VSZ
. The total virtual memory used by the process, in kilobytes.RSS
. The resident set size, the RAM portion occupied by the process.STAT
. The current process state.START
. The time the process was started.
To display the running processes in a hierarchical view, enter:
ps -axjf
Note: When using more than one ps
command option containing a dash symbol ("-"), you only need to use one dash symbol before listing the options. For instance, to use the ps
command with the -e
and -f
options, type ps -ef
.
List Linux Processes Using top Command
The top command displays the list of running processes in the order of decreasing CPU usage. This means the most resource-heavy processes appear at the top of the list:
top
The top
command output updates in real time, with the three-second default refresh rate. The top
command output contains the following categories:
PID
. Process identification number.USER
. The name of the user running the process.PR
. The scheduling priority for the process.NI
. The nice value of the process, with negative numbers indicating higher priority.VIRT
. The amount of virtual memory used by the process.RES
. The resident (physical) memory amount used by the process.SHR
. The total shared memory used by the process.S
. The process status:R
(running),I
(idle), orS
(sleeping).%CPU
. The CPU usage percentage.%MEM
. The memory usage percentage.TIME+
. The total CPU usage amount.COMMAND
. The name of the command that started the process.
List Linux Processes Using htop Command
The htop
command offers the same output as the top
command. However, it is easier to understand and more user-friendly.
Note: Most Linux distributions don't include this command. Install it with sudo apt install htop
.
The htop
command provides the following output:
htop
Use the following keys to interact with the htop
command:
- Directional keys. Scroll the process list vertically and horizontally.
- F1. Opens the help window.
- F2. Opens the htop command setup.
- F3. Searches for a process by typing the name.
- F4. Filters the process list by name.
- F5. Switches between showing the process hierarchy as a sorted list or a tree.
- F6. Sorts processes by columns.
- F7. Decreases the nice value (increase priority) of a process.
- F8. Increases the nice value (decrease priority) of a process.
- F9. Kills the selected process.
- F10. Exits the command interface.
List Linux Processes Using atop Command
The atop
command provides a more comprehensive overview of the running processes compared to the top
command.
Note: If the atop
command is not installed on your machine, install it with sudo apt install atop
.
The atop
command creates the following output:
atop
The heading section of the output provides an overview of system resources, including process and performance-related statistics and memory, disk, and network usage.
The lower section lists currently running processes and contains the following categories:
PID
. Process identification number.SYSCPU
. The CPU usage by the process.USRCPU
. The CPU usage by the process while running in user mode.VGROW
. The virtual memory amount the process has occupied since the last output update.RGROW
. The physical memory amount the process has occupied since the last output update.RUID
. The real user ID of the user that started the process.ST
. The current process status.EXC
. The exit code after the process terminates.THR
. The number of threads the process is using.S
. The current status of the primary thread of the process.CPUNR
. The number of CPUs used by the process.CPU
. The CPU percentage used by the process.CMD
. The name of the command that started the process.
Using the atop
command with the following options changes the output format:
Option | Description |
---|---|
-a | Lists active processes only. |
-c | Shows the command line arguments per process. |
-d | Sorts processes by most active resources. |
-l | Prints total values as average-per-second. |
-m | Shows memory information. |
-n | Displays network information. |
-s | Shows process scheduling information. |
-v | Prints the verbose output. |
-y | Displays individual threads. |
a | Sorts processess by most active resources. |
c | Shows the command line per process |
m | Sorts processes by memory usage. |
n | Sorts processes by network activity. |
List Linux Processes Using pgrep Command
Using the pgrep
command allows you to search for a specific process. The pgrep
command uses the following syntax:
pgrep [process name]
For instance, use the following command to search for the firefox process:
pgrep firefox
The command output lists the process PID:
Using this PID with the ps
command allows you to get more information about the process. In this example, using the PID 19327 provides information for the Firefox process:
ps -e | grep 19327
Conclusion
This tutorial explains several commands for listing and managing running processes in Linux. Choose the command that suits you best to manage your Linux system.
Next, learn about other important Linux commands.