htop - Monitor Linux processes in real time
The htop utility in Linux allows you to interactively monitor the processes in real time. It's very similar to top but has some extra features that makes it an even better command line utility for process monitoring.
Here is an excerpt from the man page of htop :
The htop utility is not bundled by default in Linux distributions but it can be easily downloaded and installed. Once the download and installation is done, this utility can be run through command line by just typing in 'htop'.
Here is how an htop window looks like :
Here is an excerpt from the man page of htop :
Htop is a free (GPL) ncurses-based process viewer for Linux.
It is similar to top, but allows you to scroll vertically and horizon‐
tally, so you can see all the processes running on the system, along
with their full command lines.
Tasks related to processes (killing, renicing) can be done without
entering their PIDs.
The htop utility is not bundled by default in Linux distributions but it can be easily downloaded and installed. Once the download and installation is done, this utility can be run through command line by just typing in 'htop'.
Here is how an htop window looks like :

The whole window above can be divided into three sections. The top-left section represents the CPU and memory usage information while the top-right section represents Load average, uptime etc. The rest of the information is nothing but a real time view of processes with statistics like priority, CPU and memory consumption etc.
Let's understand these sections one by one.
Let's understand these sections one by one.
CPU and memory usage
The numbers 1 & 2 (top-left) represent the number of cores in the system. So, as you can see, in my system there are two cores. The bars next to these numbers represent the load on these cores where different bar colors represent different information. Below core related information lies the memory and swap information. This information also follows the same format ie progress bars of different colors.
Here is what these different colors mean :
Default mode
- Blue: low priority processes (nice > 0)
- Green: normal (user) processes
- Red: kernel time (kernel, iowait, irqs...)
- Orange: virt time (steal time + guest time)
Detailed mode
- Blue: low priority threads (nice > 0)
- Green: normal (user) processes
- Red: system processes
- Orange: IRQ time
- Magenta: Soft IRQ time
- Grey: IO Wait time
- Cyan: Steal time
- Cyan: Guest time
Memory meters are more straightforward:
- Green: Used memory pages
- Blue: Buffer pages
- Orange: Cache pages
Information Source : This thread on serverfault
Load average and other information
On the top-right side of the htop window, there is information related to tasks, threads, Load average and system uptime. Load average is the measure of work that system performs. For a system with single core, a load average of 1 indicates 100% CPU usage. For example, in my case, a dual core system with load average of 0.15 means very less load on CPU. If it goes up to 2 then that would mean 100% utilization of both cores. Also, you can see three numbers next to Load average, these represent the average load for 1 min, 5 min and 15 min respectively.
Process related information
All the area below the above described information is dedicated to process specific information. The information for each process is divided into various columns. Here is what each columns means : - PID: Process ID of a process
- USER: User owning the process
- PR: Priority of the process.
- NI: The nice value for a process.
- VIRT: Virtual memory consumption.
- RES: Physical RAM consumption in kilobytes.
- SHR: Shared memory consumption.
- S: Process status (sleeping, running etc).
- CPU%: CPU consumption
- MEM%: Physical RAM consumption.
- TIME+: Processor time used by the process.
- COMMAND: Command that started the process.
Enable/Disable features through F-keys
1. Enter setup through F2
When you press F2, you enter the setup menu. Here you can define the settings that you want htop to adopt. For example, I used the right arrow key to reach 'Task counter [Text]' and then pressed enter a couple of times to change the display settings to 'Task counter [LED]' (see blue highlighted text in the snapshot below).

If you see the top-right in the window, you see that information related to task and thread is now being displayed into LED format. Similarly you can tweak other settings from here.
2. Search processes through F3
From the main window, if you press F3, htop enters search mode. In this mode a text box pops up where a process name can be entered and htop searches that process.
Here is an example :
Here is an example :

You can see from the snapshot above, I searched for Firefox and htop highlighted the relevant process.
3. Display tree view through F5
A tree view of processes can be displayed by pressing F5 on the main htop window.I tried the same and here is what I got :

So, processes were displayed in a tree view.
4. Send signals through F9
Through F9, htop even facilitates sending signals to a selected process. The main use of this feature is to kill a process by sending a particular signal. Here is how the window looks like when F9 is pressed :

You can use mouse to select the process and signal and then press enter to send the signal to the selected process.
5. Color tag a process through space key
It's a very useful feature where-in you can color tag the process you select to monitor. This helps a lot as tagged process always stand out of the crowd due to their color and hence are easy to keep track of. To tag a process, just select one and hit space key.
Here is an example :

I tagged three processes and you can see in the snapshot above, all of them were displayed in yellow colour. The tagged process can be untagged by selecting them and pressing 'U'.
Similarly there are other F-keys that can be used to enable/disable various other features. One other thing that I want to highlight is the command line options. When the htop is run from command line, there are various command line options that can be used for specific purposes.
Let's discuss some of them here.
Let's discuss some of them here.
htop command line options
1. Start htop in no-color mode using -C option
The option -C can be used to start htop in no-color mode.
Here is how htop window looks in no-color mode :
Here is how htop window looks in no-color mode :

2. Show only processes of a given user through -u option
The option -u can be used to display processes of a given user.
Here is an example :
$ htop -u root
$ htop -u root

So you see that all the processes of root user were displayed.
3. Sort a column through -s option
Through -s option provided by htop, you can sort any column of the process information in the htop window.
Here is an example :
$ htop -s PID
