Tuesday, 12 April 2011

Htop a better command line system monitor utility for your linux

Most of the people will be familiar with the top command that is used to check the processes running in our linux distro and it also gives vital information like memory usage, cpu usage etc. But most of the cases it seems that the top command itself is not enough and I often feel that the top utility is not that much accurate. This started me looking for a better command line alternative for top. Thus I stumbled upon an awesome command line system monitor utility called "htop".

Htop is, according to its website is "an interactive process viewer for linux". It is written in C programming language and it uses ncurses library. It is created to overcome the usability issues and limitations of the top utility in linux. It is created by Hisham H. Muhammad and he has named it after him. That is htop is the short name for Hisham's top.

In short we can tell that htop is an advanced version of top which we can even use mouse to control it. There are many more options given in htop which is easy to use. I always felt that htop is much more accurate than top. Let's have a look at the differences between top and htop and other functionalities.

Htop gives better idea about the cpu usage, memory usage, swap memory etc by using different color paterns. There are options to search for a particular process, sort processes by different parameters like memory usage,cpu usage etc, view a particular process as tree, option to kill a process etc.  And more over you can use your mouse to select and view information about a process.

I like the search feature of htop. It is very useful. For example, if you want to view the memory usage of firefox, you can click on the search option at the bottom of the terminal or you can use the keyboard shortcut F3 and type firefox, and it will highlight the firefox entry in the htop window.  You can read the comparison between top and htop below (from htop website):

Comparison between htop and top
  • In 'htop' you can scroll the list vertically and horizontally to see all processes and complete command lines.
  • In 'top' you are subject to a delay for each unassigned key you press (especially annoying when multi-key escape sequences are triggered by accident).
  • 'htop' starts faster ('top' seems to collect data for a while before displaying anything).
  • In 'htop' you don't need to type the process number to kill a process, in 'top' you do.
  • In 'htop' you don't need to type the process number or the priority value to renice a process, in 'top' you do.
  • 'htop' supports mouse operation, 'top' doesn't
  • 'top' is older, hence, more used and tested. 
Here is  the decription of htop by the author Hisham himself:

"I believe the number displayed by htop is a more meaningful metric of resources used. The number showed by the memory meter is the total memory used by processes. The additional available memory is used by the Linux kernel for buffering and disk cache, so in total almost the entire memory is in use by the kernel. The number corresponds to the green bars; the blue and brown bars correspond to buffers and cache, respectively (as explained in the Help screen accessible through the F1 key). Numeric data about these is also available when configuring the memory meter to display as text (in the Setup screen, F2)"


If you are using Ubuntu it is simple as below:

  • sudo apt-get install htop

This will install htop. Alternatively you can search for it in Ubuntu software center and install it. If you are using any other distro, you can install it using the package manager in your distro. See the download page of htop for your distro. All the important linux distros are listed there.

No comments:

Post a Comment