Windows has its famous task manager. Linux has several GUI and command line system monitors. Every Linux system comes with a few of them.
On the command line, the top command may be the goto command to quickly check system resource usage.
Using the top command outside of the process display can be tricky. And that’s where htop comes out on top. Puns aside, htop is a top-like utility but with an improved, user-friendly interface.
In this guide, I will show you how you can install and use htop on Linux.
Install the htop utility in Linux
You won’t find htop pre-installed on the majority of Linux distributions, but being one of the most popular utilities, you will find htop in the default repositories of almost all Linux distributions.
So if your machine is powered by something that is Debian/Ubuntu based, the following command should do your job:
sudo apt install htop
Similarly, if you are on Fedora, you can use the given command:
sudo dnf install htop
And there is also an instant package available if you want to avoid creating packages from source:
sudo snap install htop
If you’re on something else or want to build from source, you can always refer to htop’s GitHub page for detailed instructions.
Once the installation is complete, you just need to use the htop command in the terminal, and it will mirror all the processes running on your system:
In htop there is a color code for each section, so let’s look at what each color indicates when using htop.
What the different colors and statistics indicate in htop
So let’s start with the CPU usage bar, because it uses the maximum number of colors.
CPU usage bar
- Green: Resources consumed by user processes.
- Blue: Indicates low priority threads.
- Red: CPU resources used by system (kernel) processes.
- Water Blue: Indicates virtualized processes.
- Green: Memory used by system processes.
- Blue: Memory used by buffer pages.
- Orange: Memory allocated for cache pages.
- Tasks: 166 shows that there are a total of 166 running processes.
- 1249th indicates that these 166 processes are managed by 1249 threads.
- 1 race indicates that among these 166 processes, only one task is running.
- Load average shows the average system load over a period of time. Since my system is Hexa-Core, anything below 6.0 is fine. This number can exceed, for example 6.1, so that subsequent processes must wait for current tasks to complete.
- 1.86 is the average load of the last minute.
- 1.75 is the average load of the last 4 minutes.
- 1.47 is the average load of the last 15 minutes.
- Availablity is only hours since you logged in.
Now let’s move on to the actual implementation part.
How to use htop in Linux
Since the htop is mainly used to check system resources, let’s see how you can sort processes based on resource consumption.
Sort processes based on resource consumption
The easiest way to sort processes by CPU and memory usage is to use your mouse pointer. Hover over the CPU or Memory section and click on one of them.
And there you will see an icon of a triangle
△ and based on that, you can sort the process from highest to lowest resource consumption:
But if you are dealing with remote servers, you may not have the privilege to use a mouse and in those cases you can use hotkeys.
Hurry F6 and it will display all available options to sort the running processes:
You can use the arrow keys to select a preferred sorting option, then press the enter key, the results should reflect as expected.
Search for a specific process
If you want to search for a specific process and its resource consumption, you can tap F3 and you will get a search prompt as shown below:
For example, I searched for htop, and it highlighted the process with a light orange color. And you can press F3 for the next result.
Filter running processes
Although searching may give you the results you expect, I find the process of filtering using keywords even more effective because it presents a list of processes.
To filter the processes, you need to press F4 and type the process name. For example, I filtered out processes related to gnome-boxes:
kill the process
Once you have managed to find the most resource-intensive and unnecessary process, all you have to do is press F9and it will present you with termination signals:
I can’t cover all 15 termination signals, we have a separate guide on the different termination signals, so you can refer to that guide if you intend to learn more about them.
But I will recommend you to use SIGTERM first, because it is the most efficient and user-friendly way to kill the process.
Here my goal is to add a date and time and change the color scheme to monochrome.
First, press F2and this will be a configuration prompt allowing users to change the appearance of htop:
First, hover over the
Colors sections and press enter and it will allow us to change the color scheme. From there, select the Monochrome option and press Enter to save the changes:
Now go back to the configuration option, and from there use the left arrow key to explore the available counters:
As I intend to add the date and time, I have to press enter once I find the corresponding option.
Here it will allow you to place the date and time in any of the left and right columns and you can use the up and down arrow keys to change the order of the columns.
So I placed the date and time counter with the last style option (you can change the style using the spacebar):
Once you are done aligning the date and time, press the Enter key to save the changes and F10 to close the setup prompt.
In this guide, I explained how you can install the htop utility in different Linux distributions and how you can use some basic features of htop to manage system resources efficiently.
But htop can do a lot more and for that and to learn more you can always refer to its man page, and we have a detailed guide on how to get the most out of the man page in Linux.