amazon media file explorer download upload index folder image licenses menu widget Play Pause profile-settings more dots-two-horizontal dots-two-vertical more-vertical pending google-plus hangouts facebook instagram whatsapp spotify telegram twitter vine renren rss youtube twitch vimeo flickr dribble behance deviantart 500px steam github soundcloud skype reddit linkedin lastfm delicious stackoverflow pinterest xing flattr foursquare yelp World

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:

https://youtu.be/Io_sZyKmFbI

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:

https://youtu.be/vR6nSANZyX4

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

Related Post(s)

  • How To Access Windows 10 Drive/Folder in VirtualBox

    To access Windows drive or folder in your Guest OS, you first of all, install VirtualBox guest utilities: sudo apt-get install virtualbox-guest-utils You then Add a shared folder by going into: Setti

  • 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.

  • Installing WP-CLI In a GNU/Linux Server

    WP-CLI is a command-line interface for WordPress. It can also be used with ClassicPress, as they are no differences in their usage, maybe just minimal if you are updating or downloading new ClassicPr

  • 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

  • Mounting and Unmounting Cloud Storage With (Rclone) in GNU/Linux

    Ever wondered if you could mount your preferred cloud storage as a virtual drive on your system? Thanks to Rclone, you can mount and access different kinds of cloud storage from a file manager, I'll