How to see running processes on Linux

Posted on

How to see running processes on Linux

While Windows OS makes viewing running processes simple with ctrl+shift+esc, Linux requires a different approach, often from the terminal. This article explains how to monitor processes on Linux.

What is a Linux process

In any OS, a process is an active task that the server is working on. This includes opened applications like explorers, browsers, calculators, or even notepads. Each application is a process that runs until it’s closed. Many programs, like browsers or audio drivers, can run multiple processes.

Processes can run in the background (like VPNs) or the foreground (the app you are currently using).

Linux assigns each process a unique process identification number (PID) for easy tracking.

Understanding which processes are overloading your server and knowing how to manage their priority or terminate them is crucial for server stability.

How to list all processes in Linux

You can use three primary commands:

ps

Provides a static snapshot of the processes running on your server.

top

Provides a real-time system status summary, including RAM usage, CPU percentage, SWAP memory, process uptime, etc.

htop

Offers a more detailed, interactive view of all system processes. Unlike `ps` and `top`, you can use a mouse to select and interact with processes.

Getting to know ps command

The `ps` command is like a static version of Windows Task Manager. While the output may vary slightly between UNIX-like operating systems, it generally displays the PID, terminal name, running time, and the command used to launch the process. Using arguments such as:

ps -au

Shows all running processes, including those used by other users on your server. Additional arguments allow you to customize the displayed data.

ps -A

Shows all the running processes of all users on the server.

ps -U

Displays CPU load percentage, RAM consumption, the process owner, and the process code.

ps -X

Displays processes not executed from the terminal, such as daemons and system processes launched during system boot.

Getting to know top command

This command most closely resembles Windows Task Manager. Use it to quickly identify resource-intensive processes. The most demanding processes will be listed at the top.

Unlike `ps`, `top` provides dynamic, real-time data updates. Here’s a helpful cheat sheet (case-sensitive):

  • k – Kills a process
  • M – Sorts the list by memory usage.
  • N – Sorts the list by PID.
  • r – Changes the priority of a process.
  • h – Displays the help window.
  • z – Displays running processes in colors.
  • d – Changes the refresh time interval.
  • c – Displays the absolute path of a process.
  • q – Stops the top command.

Getting to know htop command

htop is an improved version of `top` that allows mouse interaction for scrolling, clicking, etc., making server management faster. It also uses color-coding to highlight important information for better readability. If `htop` is not installed, you can install it using:

$sudo apt install htop

Instead of manually entering the process ID to kill a process, htop allows you to kill a process by simply clicking on it.

Here’s another helpful cheat sheet:

  • F1 – Display the help menu.
  • F2 – Open htop setup.
  • F3 – Search for a process.
  • F4 – Filter the processes by name.
  • F5 – Display processes in a tree view.
  • F6 – Sort processes by any column.
  • F7 – Decrease the priority of a process.
  • F8 – Increase the priority of a process.
  • F9 – To kill a process.

Conclusion

Monitoring processes in Linux isn’t as complicated as it might seem initially, it just requires a slightly different approach. With practice, you might even find it more efficient than Windows. We hope you found this guide helpful!


Blog

Leave a Reply

Your email address will not be published. Required fields are marked *