htop Installation Explained

htop Installation Explained



htop is a great interactive process viewer for Linux servers, which is very robust and good alternative of  ‘top’ command utility. The htop tool is basically text based interface written in C programming(using ncurses library) by Hisham Muhammad with the help of a group of code contributors.

He came up with an idea to write htop in order to replace the standard ‘top’ command line tool in Unix/Linux operating system. It provides the same result as top, but with a full list of all running processes instead of showing  top resource consuming processes. It uses colors to give you visual information about memory, swap & CPU status.

Here are the some differences between htop and top command utility:

* htop supports mouse interaction while top doesn’t. You can scroll the list horizontally and vertically to see all processes and complete command lines.
* Data displayed by htop is Color formatted & nicely sorted  while top only shows white text with black background.
* Tree view of processes, SMP (symmetric multiprocessing) and other features available in htop.
* htop starts very quickly by gathering information while top takes time to collect data before displaying anything.
* When debugging memory leaks in applications, htop displays a more convenient, mouse controlled cursor environment for killing processes as compared to top.
* You will need to wait each time when you press any unassigned key in top, especially its annoying when there are multiple key sequences are triggered by accident.
* Like top you don’t need to type the process number to kill a process in ‘htop’. Just by selecting the process and pressing f9 button on keyboard or clicking ‘kill’ option will delete the process instantly.
* In htop there is no need to type the process number or  priority value to renice a process as same as you do in top.
* top is old and hence it is widely used and tested.

Installing htop on Linux server:

To install htop on CentOS (5.X)  or Redhat Linux server easily via yum package manager, you will need to have rpm forge package repository installed. To get the RPM downloaded and install for your architecture (32bit or 64bit), Follow the commands:

32-bit :
# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
# rpm -Uhv rpmforge-release*.rf.i386.rpm

64bit:
# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
# rpm -Uhv rpmforge-release*.rf.x86_64.rpm

Now you have installed rpm forge repository, then install the htop package easily via yum.

# yum install htop

Now you can execute the command htop from Linux shell:

# htop

Downloading htop  from source
:

Browse the http://sourceforge.net/projects/htop/ and copy download URL

Log into server shell:
# cd /usr/src/
# wget http://sourceforge.net/projects/htop/files/latest/download
# tar zxvf htop-1.0.1.tar.gz
# cd htop-1.0.1
# ./configure

If you will get the following error message, then make sure that you have installed  ncurses-devel package by running (# yum install ncurses-devel)

“configure: error: missing headers:  curses.h”

Then run these commands:
#make all
# make install

It will install the htop binary in /usr/local/bin/htop  and you can start using htop:

#htop

Some useful tips :
To set delay time in 2 seconds :
# htop -d2

To see the process run through specific user :
# htop -u apache (It will list all process by apache user only)

Cheers!