If you spend any time in the terminal, you have probably used top to check what your system is doing. It works. But it is also ugly, hard to navigate, and requires memorizing too many key combinations.
htop is the replacement you actually want to use. The htop command gives you a color-coded view of your CPU cores, memory usage, swap, and running processes all on one screen. You can scroll, sort by clicking column headers, and kill processes without typing PIDs. I have been using htop for years and I honestly forget top even exists.
This guide covers 10 practical ways to use the htop command for real system monitoring and troubleshooting. Everything here works on any Linux distribution.
Installing the htop Command
Before you can run the htop command, you need to install it. The package is available in every major distribution’s repositories.
# Debian / Ubuntu / Linux Mint
sudo apt install htop
# Fedora / RHEL / CentOS
sudo dnf install htop
# Arch / Manjaro
sudo pacman -S htop
# openSUSE
sudo zypper install htop
# macOS (Homebrew)
brew install htop
That is it. No config files, no daemons. Once installed, type htop and hit Enter.
Understanding the htop Command Screen Layout
The first time you run the htop command, the screen has four main areas. At the top you see CPU bars. One bar per core, color-coded by usage type. Blue is low priority, green is normal, red is kernel, and yellow is virtual memory wait time.
Below that is the memory bar and the swap bar. Green is used memory. Blue is buffers. Yellow is cache. This layout gives you a complete picture of your system without opening three different tools.
The main area lists every running process. Column headers show PID, user, CPU percentage, memory percentage, and the command being run. You can click any column header to sort by that value. No flags needed.
The bottom of the screen shows function key shortcuts. F1 for help, F2 for setup, F3 for search, F4 for filter, F5 for tree view, F6 for sort, F9 for kill, F10 to quit.
Sorting Processes with the htop Command
By default htop sorts by CPU usage. This is useful when something is pegging your processor and you want to find the offender fast. But sometimes you need to find a memory leak instead.
Press F6 to enter sort selection mode. A menu pops up with options like PERCENT_CPU, PERCENT_MEM, PID, USER, TIME, and more. Use the arrow keys to highlight one and press Enter. The process list reorders instantly.
You can also sort by clicking the column headers with your mouse. I use this constantly. It sounds small, but being able to click “MEM%” to find the process eating 4GB of RAM instead of remembering a flag makes the htop command much faster than top.
Killing Processes Using the htop Command
This is the feature that made me switch. In top, killing a process requires writing down the PID, pressing k, and typing the number. In htop, you just highlight the process with arrow keys and press F9.
A menu appears with signal options. SIGTERM (15) is the default. That sends a clean shutdown signal. If the process ignores it, arrow down to SIGKILL (9) and press Enter. The process disappears from the list. No PID hunting. No typing.
When you use the htop command to kill a stubborn process, you can also select multiple processes at once by marking them with the Space bar.
Searching and Filtering with htop
When your system has hundreds of processes running, finding one by scrolling is slow. Press F3 and start typing. htop highlights matches as you type, similar to how a browser finds text on a page.
Press F4 for filter mode. This is different from search. Filter hides everything that does not match your text. If you type “nginx”, only nginx processes stay visible. The CPU and memory meters at the top still show your full system usage, but the process list shows only what you care about.
I use filter mode constantly when troubleshooting web servers. Type “apache” or “nginx” and the whole htop command view narrows down to just those processes.
Tree View for Process Hierarchies
Press F5 to switch to tree view. Instead of a flat list, processes are arranged under their parent processes. You can see that your bash shell spawned that Python script, which then spawned two child processes.
This is invaluable for debugging runaway processes that fork too many children. You can identify the root process and kill it instead of chasing individual child PIDs. The htop command tree view also collapses subtrees. Use the left and right arrow keys to expand or collapse branches.
Customizing the htop Command Display
Press F2 to enter setup mode. This is where htop really shines over top. You can rearrange meters, change colors, and add new columns to the process list.
The left column shows available meters. The right column shows your current layout. Use the arrow keys to select a meter and press Enter to add it. Press F7 or F8 to reorder items. You can add meters for load average, uptime, clock time, battery status, and more.
In the Display options tab you can change the color scheme. The default green-on-black is fine, but I prefer the monochrome scheme for servers where I am running the htop command over SSH. It reduces visual clutter.
All changes are saved automatically. You set it once and every future session uses your layout.
Command Line Options for htop
htop accepts several flags that change its behavior without needing the interactive interface.
# Show only processes owned by a specific user
htop -u www-data
# Start in tree view mode
htop -t
# Set update delay to 2 seconds (default is 1)
htop -d 2
# Show processes as a process tree with filter
htop -t -u nginx
The -u flag is useful if you manage a system where multiple services run under different users. Running the htop command with htop -u mysql shows only MySQL-related processes. No scrolling through irrelevant output.
Using htop in Scripts and Pipelines
htop is primarily an interactive tool, but you can use it in scripts too. The -C flag forces monochrome mode, which works better when redirecting output to a file.
# Save process snapshot
htop -C -d 300 -t > /tmp/htop_snapshot.txt
This saves a tree view snapshot with a 5-minute delay. Not something I do daily, but it has saved me once when I needed to prove a process was using too much memory over time. The htop command with -d flag runs in non-interactive mode and exits after the specified delay.
Comparing htop with top
If you are wondering whether to switch, here is the honest comparison. top is installed everywhere by default. That is its only advantage. htop needs to be installed, which takes 10 seconds with apt install htop.
Everything else favors htop. Color coding means you spot high usage at a glance. Mouse support means you click instead of memorizing keys. The ability to scroll the process list means you see every process, not just the first 20 that fit on screen. Running the htop command with a custom config you set once in F2 gives you the exact view you want every time.
On a new server, htop is the first thing I install after setting up SSH keys. It is that useful.
htop Keyboard Shortcuts
These are the shortcuts I use most frequently:
F1 Help
F2 Setup / configuration
F3 Search
F4 Filter
F5 Toggle tree view
F6 Select sort column
F7 / F8 Decrease / increase niceness (renice)
F9 Kill a process
F10 Quit
Space Tag a process
u Show processes for one user
p Toggle program path / basename
I Invert sort order
H Toggle user threads
K Toggle kernel threads
You do not need to memorize all of them. I only use about six regularly: F3, F5, F6, F9, u, and the arrow keys. The htop command with just those shortcuts replaces 90 percent of what I used top -c and ps aux and kill for.
Get More from Your Terminal
htop works great on its own, but it fits into a broader terminal toolkit. If you pair it with fzf for fuzzy searching, you get an interactive process killer that lets you select processes by typing partial names. The bat command gives you a better cat with syntax highlighting. And ripgrep lets you search through log files at speeds that feel instant.
The official htop website has the latest release information and changelog. The htop GitHub repository tracks all development and issues. For the full command reference, read the htop man page.
Give it a try. Run the htop command right now. The colors alone make system monitoring more bearable.