facebook youtube pinterest twitter reddit whatsapp instagram

Beginners Guide To Using (htop) In Ubuntu

In your server, there are lots of ways you could view a system resource usage, as well as the ability to kill a misbehaving or resource hog processes, for example, you can use the kill command to gracefully kill a process, learn more about Dealing With Misbehaving Processes in Your Server.

What if I tell you that there is a better way to go about it, which is where the htop utility comes in...

htop is an interactive process viewer that allows you to scroll vertically, and horizontally, this way, you can see the processes running on the system, along with commands running the process, the good thing about this utility is that it features mouse support, and on top of that, you can kill processes without the need of figuring out their PIDS.

If you are running Ubuntu 18 and above, then you most likely would have htop installed by default, if you don't already have htop installed, you can install it with apt:

sudo apt install htop

To get started with htop, simply run htop at your shell prompt, but I love to run it as root, this would give me an option to kill processes:

sudo htop

htop view

At the top left section of the htop display is the progress bar for each of your CPU cores (I have one core in the screenshot above), plus a usage bar for both memory and swap.

The CPU usage bar displays the used percentage of the CPU, the memory bar shows the used/total size of the memory, while the swap bar shows the used/total size of the swap.

At the top right section of the htop display are the number of Tasks you have running, Load average, and your server uptime.

The lower section of the htop display will show you a list of processes running on your server, with a column showing you the user running, Its PID, memory, and CPU being consumed by each process, and the command being run.

To scroll the process list, you can use your arrow keys to navigate up and down through the list, and here is what I love about htop, you can use your mouse to sort the list of processes, e.g if you click on MEM% or CPU%, the process list will be sorted by memory or CPU usage respectively.

Watch the below video for an illustration:


At the bottommost part are short-cut keys you can utilize for even more advance stuff, I have highlighted what the major functions are used for below, and also include a video for illustration:

F2 or Capital Letter "S" This takes you to the setup screen where you can configure the meters displayed at the top of the screen, set various display options, choose among color schemes, and select which columns are displayed, in which order.
F3 or / It Incrementally searches the command lines of all the displayed processes. The currently selected (highlighted) command will update as you type. While in search mode, pressing F3 will cycle through matching occurrences.
F4 \ This is similar to the search function, but in this case, it only shows processes whose names match with what you typed
F5 or small letter "t" This shows the process in a tree view, the way it works is organizing the processes by parenthood, and layout the relations between them as a tree. This is useful in a situation where you are stopping a process only to have it immediately respawn, you would need to know what the parent of that process is in order to stop it from resurrecting itself.
F6 This is the sorted view, this is the same as clicking on MEM%, CPU%, etc
F9, or small letter "k" The kill process sends a signal which is selected in a menu, for example, Signal 15(SIGTERM) kills the process gracefully, and the signal 9(SIGKILL) force stop a process ungracefully.
F10 or small letter "q" Quite htop

Watch the below video for an illustration:


htop can really be useful for monitoring system processes, and their usages!

Related Post(s)

  • Send Mail with Attachment Using Mutt in GNU/Linux

    Mutt is a powerful text-based mail client for Unix/Linux operating systems. It features color support, message threading, MIME support...

  • Using Pageant To Automatically Authenticate SSH key in Putty

    I can't count how many times I have typed my ssh key passphrase whenever my ssh connection times out, it is so annoying and repetitive. Well, thanks to the putty pageant, you can do that seamlessly.

  • How To Send Mail To Multiple Addresses Using (mailx)

    In this guide, you'll learn a couple of ways you can send mail to multiple addresses using mailx. mailx is a utility program for sending and receiving mail. I assume you already have mailx command, i

  • Monitoring Multiple Log Files In RealTime With MultiTail (Ubuntu)

    Oh my... I really find scanning through the logs file time consuming, and painful. Luckily for me, I founded Multitail, which is an awesome, and powerful tool for not only browsing through several f

  • Test Your Internet Download Speed from Terminal Using (Fast)

    Fast is a tiny utility program for testing your internet download speed from the terminal, to get started, you simply install via the snap store (Ubuntu): sudo snap install fast If you don't have sna

  • Access A Web Page In GNU/Linux Using (Links) [Web Browser in Text Mode]

    Links is a text-mode World Wide Web (WWW) browses that can be used to view a web page either via a local (file://) or remote ((http:// or ftp://) URLs. To get started with Links, install it using the