Measure Linux system resources using htop, atop, top

In this post, we will look at a few tools that will help us monitor and determine which processes consume most resources on your Linux machine. Three terminal based tools – atop, htop, and top For the experienced hands, a terminal and “*top” command may be familiar. For those who may not be adept with these commands, read on. If you would like to check out website monitoring tools, read my posts on this topic here and here .

Click below for the audio version of this post

If you would like to check out website monitoring tools, read my posts on this topic here and here. Back in the days I used Windows, that could be brought up by pushing ctrl+alt+del . This was a tried and tested way to figure out resource usage. Also to find out the naughty and un-responsive processes, that hogged up memory or processor cycles. I have not used Windows for quite a while now, bit I am leaving you with an image from Windows10.
Task Manager in Windows 10
Task Manager in Windows 10. Source: Wikimedia Commons
Incidentally, the machine I am using to post this blog is an AMD Ryzen powered Lenovo Thinkpad that runs dual boot Windows 11/ Linux Manjaro.

Measure Linux system resources

In Linux, like always, there are multiple ways of achieving a similar result. I will cover three terminal based tools below.

“htop” for monitoring linux system resource use

Using htop on a Linux server to monitor system resources

“top” can also explain what processes consume system resources

Using top on a Linux server to monitor system resources

“atop” is more complex, but very powerful resource management tool

Using atop on a Linux server to monitor system resources Sometimes, one or two processes can run awry and chew up system resources. This slows the entire computer. That’s where monitoring plays an important role. Case in point: while I was updating this post, Firefox and Dolphin (file manager for KDE desktop) took up a lot or RAM, as seen in the below screenshot. This post was originally published in August 2021 and has been updated since then. Links and Resources:

What about graphical Tools?

Linux desktops do offer graphical tools that help in monitoring system resources. KDE Desktop, which I use, has a tool called KDE System Monitor. A screenshot from my desktop with that tool running forms the feature image for this blog post!
KDE System Monitor Showing RAM and CPU usage for a KDE Desktop on Manjaro. Blog of Amar Vyas
KDE System Monitor Showing RAM and CPU usage for a KDE Desktop on Manjaro.
Update March 2022: using vmstat for checking system resource usage I recently decided to brush up my knowledge of Linux commands, and a familiar yet lesser known command `vmstat` came to mind. Below are some of the ways in which you can use this command to find out how much RAM is being used. You can find the output form my Lenovo Thinkpad.
$ vmstat -s
      6990192 K total memory
      3474820 K used memory
      1533028 K active memory
      4361344 K inactive memory
       127464 K free memory
        84132 K buffer memory
      3303776 K swap cache
      1048572 K total swap
       751992 K used swap
       296580 K free swap

Similarly, the `iostat` command gives information on CPU and disk usage.You can see the version of Linux Kernel, the cpu achitecture, disk read and write speed and cpu steal among other information. This post on techmint has some useful information on using the above two commands.

Linux 5.16.11-arch1-1 (sanganak-tp) 	03/03/22 	_x86_64_	(12 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           5.89    0.28    6.13    0.04    0.00   87.66

Device             tps    kB_read/s    kB_wrtn/s    kB_dscd/s    kB_read  
nvme0n1           6.66       562.63        54.21         0.00   52507999

Monitoring System Resources Remotely

If you are using a server or a headless machine (Computer without a graphical interface), then you can monitor the resource usage remotely using “*top” via a terminal. You will have to ssh into the server in order to do so. For example, I used this method to check system resources on a storage server from Inception Hosting I have in the United States.
$ ssh Stor
Linux inph.vyas 5.10.0-10-amd64 #1 SMP Debian xxx

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sat Jan 29 18:54:27 2022 from
[email protected]:~$ htop

Using Third Party Monitoring Tools

For the more experienced hands, tools like Grafana, Netdata, or Hetrix Tools might come in handy. I was recently introduced to the Hetrix Tools Monitoring Agent through this discussion on LowEndTalk. Note: You can watch the most recent system report of this server by clicking here.

Wrapping up: System Monitoring Tools for Linux

There are several ways by which one can monitor the system resources and use of cpu, disk space, and RAM. As they say, ‘there is more than one way to skin a cat‘. One of the beautiful things about Linux and Open Source world is that there are several ways to achieve the same result. And many great command line tools to achieve that. In this post, we just mentioned a few that barely scratch the surface.
This post was updated on 2022-03-03