This post was originally published on go2linux.org on August 6, 2007. The domain is no longer mine, but I am the original author. I am republishing it here on garron.me with corrections and improvements.

Almost every Linux user has used top to check how the system is doing — running processes, CPU usage, memory. But top has limitations: it truncates long process names, the interface is not very intuitive, and killing a process requires you to know its PID and type it manually.

That is where htop comes in.

Installing htop

# Debian / Ubuntu
sudo apt install htop

# Fedora / RHEL / CentOS
sudo dnf install htop

# Arch Linux
sudo pacman -S htop

Basic usage

Just type:

htop

At the top you will see a bar for each CPU core, plus memory and swap usage. Below that is the process list, sorted by CPU usage by default.

Keyboard shortcuts

This is where htop really shines over top. You do not need to memorize cryptic key combinations — the function keys are shown at the bottom of the screen.

Key Action
F2 Setup — customize colors, columns, and display options
F3 Search — find a process by name as you type
F4 Filter — show only processes matching a string
F5 Tree view — show processes in a parent/child hierarchy
F6 Sort — choose which column to sort by
F9 Kill — send a signal to the selected process
F10 Quit
Space Tag a process (to kill or act on multiple at once)
u Filter by user
t Toggle tree view

Mouse support

htop supports the mouse. You can click on a column header to sort by it, click on a process to select it, and click the function key labels at the bottom to activate them. Not all terminals support this, but most modern ones do.

Useful flags

Show processes as a tree from the start:

htop --tree

Sort by memory usage:

htop --sort-key PERCENT_MEM

I use htop daily on every server I manage. Once you get used to it, going back to plain top feels like a step backwards. The first tool I install on every Linux system is htop.