How to view CPU usage in linux server

Why is it important for us to know the current load on the server

To server work correctly, the load (LA) must always be within the normal range. With the growth of visitors, the software causes a big load and it is important to monitor the available processor resources and expand it in time when is necessary. When the load on the server is big, it is important to be able to figure out what cause it, so you can optimize your CPU usage. We’ll show you how to check server current resource usage.

How to check cpu load on server using “htop”

First we have to login to our server and install “htop”

Debian/Ubuntu: apt install htop
CentOS/RHEL: yum -y install htop

After installation, run “htop” and see which processes you have at the top, so we can “kill” the process. Use the up-down arrows to select process which you want to “kill”, press F9, and then Enter. After that, we can restart our software and observe system CPU load.

How to check CPU load on the server with “ps”

We also login to the server and execute the command: “ps -aux -sort -pcpu” and see which process is at the very top. It shows the current load in the terminal.
It is important for us to look at the parameters:
“USER” – which user ran the command
“PID” – process ID
“%CPU” – how much this process loads the processor

To “kill” the process that is making load on the server, we execute the command:

kill -9 "PID"

How to check CPU load on the server with “top”

Just enter your server and type command (same on Debian/Ubuntu and CentOS/RHEL):


After running the command, you’ll see this

Here you will see same information as in “htop”, but in more “oldish” style and the process which uses most of CPU should be always on top.

We hope this information was useful to you!