How to List Running Processes in Linux: A Beginner’s Guide

Do you need to see all the processes running on your Linux server and find out which one consumes your resources the most? Look no further, because, in this article, we will explain how to enumerate processes by using several common Linux commands.

Introduction to Linux processes

A process is the execution of a program. They can be launched when you open an application or when you issue a command through the command-line terminal. However, an application can run multiple processes for different tasks. For example, Google Chrome will start a different process each time a new tab is opened.

A process can be started as a foreground or background process. Each Linux process is assigned a unique PID (Process Identification Number).

Occasionally, processes can consume a lot of resources and need to be eliminated. Alternatively, times when you may want to change the priority level of a process, so the system will allocate more resources to it. Regardless of the case, all of these tasks require you to do the same thing: list the processes running on Linux.

How to list running processes on Linux?

To enumerate processes in Linux, use one of three commands: ps, top, or htop. The Ps command provides a static snapshot of all processes, while top and htop sort by CPU usage.

Let’s dig deeper into each of them.

Using the

“ps” command

The ps (Process States) command produces a snapshot of all running processes. Therefore, unlike the Windows task manager, the results are static.

When this command is used without any additional arguments or options, it will return a list of running processes along with four crucial columns: the PID, the terminal name (TTY), the runtime (TIME), and the name of the command that starts the process (CMD). You can use ps aux to get more detailed information about your running processes. Here’s a breakdown of each argument:

  • One option generates all running processes for all users
  • on the system.

  • u provides additional information such as percentage of CPU and memory usage, process status code, and process owner
  • .

  • Option X lists all processes not executed from the terminal. A perfect example of this is daemons, which are system-related processes that run in the background when the system starts.

If you want to list Linux processes in a hierarchical view, use the ps -axjf command. In this format, the shell will place child processes under their parent processes. Aside from those two options, here are some other common examples of the ps command that list

running processes on Linux: ps –

  • u [username] lists all running processes for a given user
  • . ps –

  • e or ps -A displays active Linux processes in the generic UNIX format. ps
  • -T prints active processes running from the terminal.
  • Ps -C will process_name filter the list by process name. In addition, this command also displays all child processes of the specified process.

Using the

“top” command

The top command is used to discover resource-intensive processes. This Linux command will sort the list by CPU usage, so the process that consumes the most resources will be placed at the top. It is also useful to check if a specific process is running.

Unlike the ps command, the output of the top command is updated periodically. That means you’ll see real-time updates for CPU usage and runtime. Once the shell returns the list, you can press the following keys to interact with it:

Key functions or;

Note that the above keys are case-sensitive, so make sure you don’t enable caps lock.

Both the htop and

top command display the same information when listing your Linux processes, but the former offers easy-to-use features that are great for day-to-day process management

. First things first,

the htop command allows you to scroll vertically and horizontally. As such, you can see the full list of your Linux processes along with their full command lines.

In addition, the command allows you to use a mouse to select items, kill processes without inserting their PIDs, change the priority of multiple processes easily, etc.

Unfortunately, most Linux distributions don’t have this command right out of the box, so you have to install it manually.

If you use Ubuntu, you can install htop by running the following command:

sudo apt-get install htop

Once installed, type htop and you will get a list of all your Linux processes. Like the previous command, htop also has several keyboard shortcuts:

Key functions

Using the “atop

” command The

atop command is a tool for monitoring system resources on Linux. It is a full-screen ASCII performance utility that logs and reports the activity of all server processes.

Once started, atop will

display resource usage for CPU, memory, swap, disks, and network at 10-second intervals. atop will remain active in the background for long-term server scanning (up to 28 days by default).

Some of the advantages include:

Accumulates resource usage for all processes

  • and users with the same name
  • .

  • Highlights critical resources in colors (red
  • ).

  • Displays the resource usage of all processes, including those that have been completed or closed.
  • Monitors threads within processes (except unused ones).
  • Uses netatop kernel mobile to monitor TCP, UDP and network bandwidth.

You can install the atop command

by running any of the following commands:

Ubuntu / Debian

sudo apt install atop

CentOS / RHEL / Fedora

sudo dnf install atop

Once installed, run the atop command to show all process-level usage of system resources.

Listing running processes using a top command

Here is the list of available arguments and their descriptions

:

Descriptionof the command

Once the top is running, press the shortcut keys listed below to sort the processes:

Keyfunctions

Conclusion

It is important to know how to list all the processes running on your Linux operating system. Knowledge will come in handy when you need to manage processes.

Which of the three commands do you prefer? Share your thoughts in the comments section below!