Linux list processes

Linux List Processes

How to Check Running Processes in Linux Using ps, top, htop, and atop Commands

Active Linux processes consume valuable resources such as CPU time and I/O bandwidth. This becomes a problem for many small-scale systems and impacts performance significantly. With linux commands like ps, top, htop, and atop, you can get insights into your linux server. This can help you manage resource-hungry processes on your server.

Introduction to Linux Processes

A process involves the active execution of a program. When a user starts an application or inputs commands into the terminal, the operating system generates a process. Multiple processes can run concurrently.

In Linux systems, processes form integral components contributing to the process’s functionality. Every process running in Linux receives a unique Process Identification Number (PID) assigned by the operating system for efficient tracking and management. To perform various operations like listing current processes, terminating specific ones, or monitoring real-time CPU and memory utilization percentages associated with them. It is necessary to obtain information regarding currently active processes on Linux-based systems.

How to Check Running Processes in Linux

There are several methods available in Linux for monitoring running processes. Among the most frequently utilized techniques are ps, top, htop, and atop. Each of these commands serves a distinct purpose and offers unique functionalities within process management.

You can use ps to check the running processes. The top command gives you a real-time snapshot of the running processes. The htop command provides an interactive interface. The atop command helps analyze the performance of the system.

How to Check Running Processes in Linux

How to Check Running Process in Linux Using the “ps” Command

The ps command stands for process status. It gives a static snapshot of all the currently running processes. This means that the results shown to you are static.

To run the ps command, open a terminal window and type ps. This will list running processes in the following format:

ps command

The ps command lists all the processes running on your system. Hence, unlike the Windows Task Manager, the results are concrete. The PID (process ID) tells the unique process identifier of your process. TTY tells the controlling terminal of the process, TIME tells you the running time of the process, and CMD tells the name of the command that launches the process.

You can use other arguments along with ps in the command line to give more detailed information about the running process in Linux. These include:

  1. ps aux

ps aux is a much more detailed output version default output of ps command. It returns 11 columns, which give more in-depth knowledge of the running processes in the Linux system. Let us break down the ps command:

  • a: gives the list of all the processes of all the users.

  • u: gives the option to display the user's name instead of the ID.

  • x: displays processes that need to be executed in the terminal.

linux kill process

  1. ps -axjf

The ps -axjf command yields a result similar to the ps aux command with additional information about each process. This includes details such as the Process Group ID (PGID), Session ID (SID), time of initiation, and arguments passed to the commands. By arranging child processes below their respective parent process names, this command aids in presenting all processes in a hierarchical manner.

To further analyze the above ps command options and output:

  • a: lists all processes regardless of their association with a terminal.

  • x: reveals processes that are not executed from a terminal.

  • j: displays the process group ID instead of information specific to terminals.

  • f: displays the entire command line, including arguments.

linux list processes by name

How to Check Running Process in Linux Using the “top” Command

The top command helps monitor the real-time performance of the running processes. It lists the processes by their CPU utilization, meaning that a process using the most CPU will be placed at the top, which enables you to track resource-intensive processes.

To use the top command, open your terminal and type top. Press enter to see all the performance metrics and the following output.

show running process linux

The top command gives dynamic updates for the currently running processes. It gives the entire count of running, stopped, sleeping, and zombie processes, making it easier for the user to know about processes using the most resources. You can also use a list of command keys to access various functionalities. These keys include Filter, Sorting, Command, and Navigation keys. Some examples of filtering and command keys are given below.

  • k: kills a process

  • h: displays help information

  • q: quits the top mode

  • s: changes the sorting order

  • m: changes the memory display mode from % to kilobytes and vice versa

  • l: changes process listing mode (brief/ full)

  • o: enters filter mode

  • i: ignore idle processes

  • n: sort processes by numerical values

    check cpu usage linux

How to Check Running Process in Linux Using the “htop” Command

We have seen the top command in most Linux distributions and what it does. The htop command is an extended version of the top command because of its user-friendly interface. It offers advanced features to manage processes, historical data about resource usage, and interactive management of processes. It also allows you to see the process list vertically and horizontally.

To use the htop command, you must install it by typing the command below.

sudo apt-get install htop

After the installation, you can type htop in your terminal to execute the instruction.

This will open up a full screen displaying the status of processes. It will also list processes with resources like CPU usage percentage, memory usage, and time.

process in linux

The list of commands that can be applied to the processes is shown to you. On your processes, you may apply search (F3), filter (F4), kill (F9), and sortby (F6).

The following table lists the differences between top and htop.

Feature

top

htop

Interface

Interactive and full-screen

Text-based and terminal-based

Process information

Detailed

Less detailed

Process management

Advanced options

Limited options

User experience

More user-friendly

Less user-friendly

How to Check Running Process in Linux Using the “atop” Command

The atop command is helpful in monitoring processes as it provides advanced features such as CPU usage, memory usage, and I/O. It also offers interactive filtering and sorting of processes.

To use the atop command, you must install it by typing the command given below. After the installation, you can type atop in your terminal and execute the command.

sudo apt install atop

kill user process linux

This will open up an interface with an output showing the system resource utilization for all the running processes. It provides real-time insights into resource usage and historical data for up to 28 days. It also provides in-depth information about each process’s CPU usage, I/O statistics, and thread usage.

linux state process

About

Each specific process consists of multiple threads so that threads of other user processes can be executed side-by-side. You can display the thread information using the ps -lf or htop -T commands.

Did you also know that processes have parent-child relationships? This means in process hierarchy, there are parent processes and child processes. You can check these hierarchies using the ps -l or htop -T commands.

Frequently Asked Questions

How can a list of processes be filtered?

You can use options like -u, -H, -M, and -F to filter based on your system administrator requirements to guarantee optimal system performance. For example, ps -F user=root will filter processes based on the root user.

How can I sort the list of processes?

You can use arguments like -r, -F, -c. For example, ps -F ‘%CPU’ -r sorts processes by CPU usage in descending order.

How can I identify processes using excessive CPU?

You can use the top command with the -H option to see which process uses the most CPU.