Some tricks with htop

htop is an ncurses process viewer for Linux. It is somehow similar to top but much better. In this article, I will enumerate several useful tricks with htop. These tricks will be useful for those who work as a sysadmin.

1. Display processes in a tree structure

Displaying process in a tree structure is very useful, it is much easier to identify processes with a tree structure. To enable this view, you can press F5 or the key "t".

In this tree view, you can collapse or expand a specific process by pressing "+" or "-".


2. Display the setup menu

When you press F2 or "s" , the setup menu will appear, there are big 4 setup menus. In each big menu there are several submenus for you to select.

Meters: change the behavior of the meter bar
Display options: change the display options of htop
Colors: change the color theme
Columns: Choose what column needs to be displayed for the processes in the htop output


3. Change the default update interval

The default update interval of htop is around 1.5 seconds, to change it, you can use the following command to launch htop:
 htop -d n  

"n" is in tenths of seconds

4. Kill a process with htop

You can kill a process using htop. From the process list, just select the one you need to kill then press F9. A menu of signal will appear, to kill this process, select "SIGKILL" and hit Enter.


5. Kill multiple processes with htop

You can kill multiple processes with htop by grouping them first then using the SIGKILL signal. To group the processes, just select each process respectively then hit Space. The selected processes will be highlighted in yellow. To kill these processes, just hit F9 then select SIGKILL.


In case you select a wrong process, to un-select it, just hit Space again. To unselect all the selected proceses, just hit "u"
linux tips and tricks