Monitoring System Processes with Htop on Debian/Ubuntu, Fedora 6, CentOS 6, RHEL 6 & Arch Linux

pid-300x225

Prerequisites

This guide is intended for  any of the Linux operating systems listed in the title run on any client machine or VPS with SSH/VNC access. You can buy VPS server hosting if needed through Hoverdata, who look to provide high quality server hosting at affordable competitive prices.

Introduction 

Htop is an incredibly useful built in CLI tool for monitoring system processes in real-time without bypassing any important sometimes overlooked details. It is a welcome tool for server admins and average users alike, and has great flexibility when it comes to customisation of the information it provides. When top (the built in linux/unix process monitor) isn’t enough htop provides the extra depth of detail needed. Installing the program is relatively straight forward and accessible to multiple popular (and unpopular) distributions of varying different kinds. Here’s how to install and use the program.

Step 1 — Install Htop

To acquire the program follow one set of commands that appear next depending upon the Linux distribution you wanting to run htop on.

Debian/Ubuntu


To find out what architecture your OS supports (32 bit/64 bit) you can use the command:

uname -m

Fedora, CentOS , RHEL – 32 bit 

i686/1386


To find out what architecture your OS supports (32 bit/64 bit) you can use the command:

uname -m

Fedora, CentOS, RHEL – 64 bit

x86_64


Arch Linux


Step 2 –Running Htop

Like any other standard Linux program installed through a package manager you can run it on the command line by calling it with its name.

So to run htop after installing in its most basic form type:


Step 3– Main Window

This previous command invokes the program and immediately shows you all running process in real-time currently working away on the system.

Htop

Htop

 


Step 4 — Top Panel

Another set of metrics included by htop can be seen at the very top of the display.

They include:

  • A representation of CPU usage and its current percentage.
  • The total amount of system memory (RAM) being utilised currently out of the total available.
  • What portion of “Swap” (Swp) is in use as well as the total potentially available if needed. This will only be full or filling if the physical memory itself is all allocated.
  • Additionally on the far right the total number of tasks and threads are listed with the system’s “Load Average” and time spent running since boot.
f25d848b39bd49a6e13eac7dc08689af

Top Panel

 


Step 5 — Bottom Panel

Likewise at the bottom of window the command keys are shown in numerical key order.

  • F1 Help — Opens a GUI manual with terminal related help topics.
  • F2 Setup — The bulk of htop customization is done here including meter/column adjustment, display layouts, and colour schemes. Worth exploring.
  • F3 Search — A quicker way of finding a process that is currently running, must exist to locate succesfully.
  • F4 Filter — Singles out the processes in relation to what you input.
  • F5 Tree — Allows you to see what relation each process has to one and other, including which is parent/child.
  • F6 SortBy — Brings up a quick access menu that lets you sort by different categories on the fly (most are abbreviated). Works on the column names at the top.
  • F7 Nice - — This option decreases the scheduling priority of the selected process.
  • F8 Nice + — This option increases the scheduling priority of the selected process.
  • F9 Kill — Perhaps the most useful of all these command keys. Will send a kill signal to the currently selected process. You may also specify the type of signal sent. Use with caution!
  • F10 Quit — Exit htop and go back to the command line, in turn killing the process.

Step 6 — Extra Shortcuts

These make playing around and using htop even more fluid but possess much of the same functionality as other shortcuts in the program.

  • – As in List, shows a list of all the open files relevant to the highlighted process.
  • SHIFT + m — Applies a sort by memory use of all processes.
  • u — As in User, allows you to select a single user and see all processes belonging to and inherited by them individually.
  • SHIFT + p   Applies a sort by processor use on all processes.
  • Kill  Identical to F9 in that it lets you kill the selected process.
  • – Identical to F3 as it triggers the same search field.

Step 7 — Command Line Parameters

There are options to be considered before running the program too!

To delay the interval at which htop updates you can use this parameter where the value supplied is in tenths of seconds.

This example is to update once every three seconds.

Don’t like the colour schemes? Or no support for the colouring on your terminal? This one disables colour.

If you want to see only the processes and threads generated by a certain user straight off the bat.

Use this next command, where “scarlz” is the username you want to filter on.

Similarly it is possible to provide a column to sort on too. Providing you can remember the column names and values htop uses.

Here’s a sort on the Memory usage column.

Need to know what version you have installed? Here’s how.


Conclusion

So overall this is how to use htop to its fullest. There are other intricacies you’ll get to grips with as you use the program, but hopefully you agree this is a good solid base to understand and work from when monitoring. If you suspect there are processing problems on a Linux OS htop is the place to start looking in resolving plus troubleshooting these issues.

Feel free to ask any questions you may have in the comments, and we will try our best to answer them.