Site icon NexonHost.com

How to list running processes.

What is a process?

In Linux, a process is a running instance of a program. When you run a program, the operating system creates a process for that program to execute. Each process has its own unique process ID (PID) and is managed by the operating system’s kernel.

List Running Processes in Linux by Using the ps Command

The ps Linux command creates a snapshot of currently running processes. Unlike the other commands on this list, ps presents the output as a static list, not updated in real time.

The ps command uses the following syntax:

ps [options]

Frequently used ps command options include:

Running the ps command without any options produces an output similar to:

The default output includes the following categories:

Using the combination of a, u, and x options results in a more detailed output:

ps aux

The new categories of the expanded output include:

To display the running processes in a hierarchical view, enter:

ps -axjf

Filter the list of processes by user with:

ps -U [real user ID or name] -u [effective user ID or name] u

For example, showing a list of processes started by the user called nexonhost:

ps -U nexonhost -u nexonhost u

ist Running Processes in Linux by Using the top Command

The top command displays the list of running processes in the order of decreasing CPU usage. This means that the most resource-heavy processes appear at the top of the list.

The output of the top command updates in real time, with the three-second default refresh rate. The top command output contains the following categories:

While the top command is running, use the following options to interact with it or change the output format:

List Running Processes in Linux by Using the htop Command

The htop command offers the same output as the top command but in an easier-to-understand and user-friendly way.

Since most Linux distributions don’t include this command, install it with:

sudo apt install htop

Using the htop command provides the following output:

Use the following keys to interact with the htop command:

List Running Processes in Linux by Using the atop Command

The atop command provides a more comprehensive overview of the running processes compared to the top command. Start by installing the atop command with:

sudo apt install atop

The atop command creates an output similar to:

The heading section of the command 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:

Using the atop command with the following options changes the output format:

Use the following flags to interact with the atop command:

Find Process IDs Using the 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

Using this PID with the ps command allows you to get more information on the process. In this example, using the PID 1439 provides information on the firefox process:

ps -e | grep 1439

Conclusion

After reading this tutorial, you should be able to use the ps, top, htop, and atop commands to list and manage running processes in Linux.

Exit mobile version