How to see running processes on Linux

When using Windows OS seeing running processes on your server is as easy as hitting ctrl+shift+esc but on Linux, it’s a little bit more complicated because Linux doesn’t have any GUI by default and usually is operated from the terminal instead. Learn how to monitor running processes on Linux via our article below.

What is a Linux process

Any process in an operating system whether it is Linux or Windows is a task that is being worked on by the server. Every type of application you open, including the explorer, browser, calculator, or notepad is a continuous process, which will be working until you close it and the task becomes finished and the process is closed. Many programs out there can open several processes, including different browsers, or even audio driver services. 

Processes can be launched as background ones, this includes for example VPNs that are running in the background and foreground. It could be an app you currently using right now. 

Linux is famous for its consistency, that’s why each process has its own process identification number (PID). 

Understanding what is currently overloading your server and how to kill the process or lower its priority is an important step toward your server's stability. 

How to list all processes in Linux

There are three commands to use

ps

Give you a static snapshot of the processes on your server.

top

Provides you with a real-time system status summary. RAM, CPU percentage, SWAP memory, time the process is running, etc. 

htop

Provides you with a more detailed summary of all system processes. You can use a mouse to select certain processes which is not possible with the previous two commands. 

Getting to know ps command

ps command is similar to Windows Task Manager except it's static, meaning that data doesn’t change in time, because it is just a snapshot. Although the content may change from one UNIX OS to another usually it will show you the PID, terminal name, running time, and the command that has launched the process. If you are using an aux argument like this:

ps -au

You’ll get all the processes that are running including those that are being used by the users on your server. If you add additional arguments you can get different data. 

ps -A

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

ps -U

Shows you such data as CPU load percentage, RAM consumption, Owner of the process, and code of the process.

ps -X

Shows you the processes which are not executed from the terminal like daemons and various system processes that are launched by default when booting up the system.

Getting to know top command

Now this command is very close to what Windows is offering. If you wish to find the process that is overconsuming resources from your server, then that’s what you need. The most demanding process will always stay on top. 

The data is not static as with ps, but dynamic which will be updated in real-time. Here is a small hotkey cheat sheet for you to use. Warning, they are 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 enhanced version of top command offering you the ability to use the mouse, which in some cases is a much faster way to do the routine job of managing your server, this includes scrolling, clicking, and all that stuff. Also, it has color coding which helps to outline certain useful info, and quickly understand the exact output. If you don’t have it on your server you can quickly install it by typing:

$sudo apt install htop

Usually you need to write the process you would like to kill but htop allows you to do so just by clicking on the required process

Here is another hotkey cheat sheet for you. 

  • 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

Hey, as you can see, it doesn’t seem as complex as using Task Manager from Windows, it just has a different look and a little bit of a different approach. We can state that after using it for a while, you’ll start to think that Windows is not as comfortable to use as Linux. We hope this article was useful for you!



Blog