How To Install And Use Htop On Ubuntu - Linux Start (original) (raw)

htop install

Htop is a powerful system monitor that’s primarily used for checking resource usage stats. It can provide info on the overall system state (CPU, RAM usage) as well as individual processes.

It’s a useful tool for figuring out which programs or processes are occupying how much of your system resources. Aside from viewing the stats, it can also be used to find and kill processes.

Installing Htop on Ubuntu

Htop is pretty similar to the top utility, except that top is preinstalled in Ubuntu but not quite as flexible as htop. Htop is typically installed using apt, but if you need the latest version, you can install it using snap instead. Ultimately, both versions work fine.

sudo apt install htop
sudo snap install htop

After installing htop, you can launch it by entering

htop

Interpreting Htop’s Output

At first glance, Htop’s output can seem a bit overwhelming but it’s actually pretty simple to understand.

At the top, you have all the CPU cores and threads with color-coded bars and usage percentages.

Next is the memory and swap space info with color-coded bars again.

Finally, there are the remaining miscellaneous stats.

In the lower half, there are 12 columns by default. You can add additional columns or remove existing ones through the setup tool (F2), but let’s just go over the standard ones for now.

Htop Options and Shortcuts

Now that you’re able to understand the output, let’s dive deeper into actually using htop.

Filtering the Output

The default output returns a ton of info. The best way to get exactly what you need out of this info is with the SortBy option. You can press F6 and select the metric to sort by (PID, PERCENT_MEM, etc.).

If you want to search for processes using keywords, you can use Search (F3). For instance, if you enter discord, it’ll take you to the closest matching result. Pressing F3 again will cycle through the matches.

If you only want the matching results to be shown, you can use Filter (F4) instead.

Finally, you can press u to only view processes owned by a specific user.

Killing a Process

You can press F9 while a process is selected to kill it. In most cases, you should send the terminate signal (SIGTERM-15), which is highlighted by default.

Other Htop Shortcuts

The other shortcuts like F5 (tree view) or F2 (setup htop) aren’t as commonly used but feel free to check them out. Also, check the help page (F1) and manpage (man htop) if you want to read up further on htop.