Skip to content

Command Line tools To Measure Linux System Resources

In this post, we will look at a few command line monitoring tools that will help us determine which processes consume most system resources on Linux machine. These terminal based tools are atop, htop, and top . For the experienced hands, a terminal and “*top” command may be familiar.

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.

The need for process monitoring in Linux Server

With so many processes and operations running simultaneously, it’s crucial to have an accurate and efficient way of monitoring system performance. That’s where terminal-based monitoring tools come in. In this blog post, we will explore three such tools: atop, htop, and top. These monitoring tools provide administrators with insights into the system’s resource usage, process management, and other critical metrics. While all three tools share a common purpose, they each have distinct features and capabilities.

Top, the most basic tool, provides a real-time view of system processes and their resource usage. Htop is an advanced version of Top, providing a more user-friendly interface and additional features such as filtering and process tree viewing. Atop goes even further, providing detailed information about resource usage, system bottlenecks, and network activity.

Throwback : Process Monitoring in Windows

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.

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 Linux Mint.

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

Using htop on a Linux server to monitor system resources
Using htop on a Linux server to monitor system resources

`htop` offers a comprehensive overview of system resources in an easy-to-understand format. It comes equipped with features such as real-time CPU usage, memory usage, and load average monitoring.

top

`top` is a basic monitoring tool that displays real-time information about system resource usage in a concise format.

Using top on a Linux server to monitor system resources
Using top on a Linux server to monitor system resources

atop

`atop` is a powerful command-line tool that provides detailed information about system resources. It offers a wide range of features, including process-specific resource utilization, disk and network activity monitoring, and per-process I/O statistics.

Using atop on a Linux server to monitor system resources
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: when I was updating this post, Firefox and Dolphin (file manager for KDE desktop) took up a lot or RAM. htop showed me the errant process, and I could take the necessary corrective action.

Comparing features of the htop, top and atop

Table comparing the key features of htop, atop and top for a linux server. Blog of Amar Vyas
comparison of features – htop, top and atop

The above table was generated using chatGPT using Debian 11 Stable as the OS on server. Depending on operating system and version of the monitoring tool the features may change.

Graphical Tools for checking processes and resource use

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!

Using htop on a Linux desktop running KDE Neon to monitor system resources
Using htop on a Linux desktop running KDE Neon to monitor system resources

Using vmstat for checking system resource usage

Update March 2022 : 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.

$iostat

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
amar@inph:~$ htop
Representative image - running htop on a linux server using ssh session over a terminal.
Running htop on a linux server using ssh. Representative image generated using Bing AI.

Using Third Party Server 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.

Takeaways from Linux System Resources Monitoring Tools

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. Back in the day when I used lightweight Window managers like Enlightenment on Bodhi Linux, I used gkrellm extensively, which offered similar tools.


This post was updated on 6 June 2023