How to List All Processes in Linux

June 11, 2024

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.

How to list running processes in Linux

Prerequisites

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:

OptionDescription
-aLists 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.
-dLists all processes except session leaders.
--deselect, -N Displays processes that do not match the specified criteria.
-fDisplays full-format listing.
-jDisplays output in the jobs format.
-tLists all processes associated with this terminal.
-r Lists only running processes.
-u Displays processes for a specific user.
-xIncludes processes without controlling terminals.
-pDisplays processes for a specific process ID (PID).
-CDisplays processes based on command name.
--sortSorts the processes based on specified criteria.
aShows all processes for all users.
uLists processes with detailed information.
xIncludes 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

terminal output for 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
ps aux terminal output

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
ps -axjf terminal output

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
top terminal output

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), or S (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
htop terminal output

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
atop terminal output

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:

OptionDescription
-aLists 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.
-yDisplays individual threads.
a Sorts processess by most active resources.
cShows the command line per process
m Sorts processes by memory usage.
nSorts 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
pgrep firefox terminal output

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
ps -e | grep 19327 terminal output

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.

Was this article helpful?
YesNo
Sara Zivanov
Sara Zivanov is a technical writer at phoenixNAP who is passionate about making high-tech concepts accessible to everyone. Her experience as a content writer and her background in Engineering and Project Management allows her to streamline complex processes and make them user-friendly through her content.
Next you should read
Linux Commands Cheat Sheet: With Examples
November 2, 2023

A list of all the important Linux commands in one place. Find the command you need, whenever you need it or download our Linux Commands Cheat Sheet and save it for future reference.
Read more
How to Use the Linux sleep Command with Examples
February 3, 2021

The sleep command is used when it is necessary to postpone the execution of commands on the command line or in shell scripts. This tutorial lists ways in which you can utilize the sleep command...
Read more
How to Set Environment Variables in Linux
December 17, 2020

Environment variables play a significant role in setting up the system and shell configuration at the beginning of every shell session. This tutorial explains how to view, set, manage, and unset environment variables in Linux.
Read more
How to Format Disk Partitions in Linux
December 2, 2020

Formatting and mounting disk partitions in Linux is common because partitions cannot be used without this process. In this tutorial you will learn how to format and mount disk partitions with ext4, FAT32, or NTFS file systems.
Read more