How to Install Htop on Ubuntu Linux

Htop is an interactive process viewer that helps you identify CPU-hogging applications, track memory leaks in real-time, and kill unresponsive processes without leaving your terminal. Unlike the classic top command, htop provides color-coded displays, mouse support, and the ability to sort, filter, and manage processes with simple keystrokes. Whether you need to troubleshoot a slow system, monitor resource usage during development, or manage remote servers efficiently, htop gives you immediate visibility into what your system is doing.

Most Ubuntu desktop installations include htop by default, but minimal server deployments and cloud images often omit it. Installing htop from Ubuntu’s default repository ensures automatic security updates and compatibility with your system. By the end of this guide, you will have htop installed and understand how to navigate processes, adjust priorities, and customize the interface to match your workflow.

Update System Packages Before Installation

Before installing htop, ensure all existing Ubuntu packages are up to date. Regular updates maintain stability, security, and compatibility with new software.

To update your system packages, run the following command:

sudo apt update && sudo apt upgrade

As a result, this command refreshes the package list and upgrades any outdated packages.

Choose Your htop Installation Method

Ubuntu offers two primary methods to install htop: the default APT repository provides stable, well-tested versions, while Snap delivers newer upstream releases with automatic updates. Choose based on whether you prioritize stability or access to the latest features.

MethodSourceUpdatesBest For
APT (default repository)Ubuntu officialDistribution cycleMost users seeking stable, tested packages
Snap packageUpstream maintainerAutomatic, frequentUsers who want the newest features immediately

For most users, the APT method provides a stable htop installation that integrates seamlessly with Ubuntu’s package management. However, choose Snap if you need features from the latest upstream releases before they reach Ubuntu repositories.

Install htop with APT

To begin, install htop from the Ubuntu repository:

sudo apt install htop

Once the installation is complete, verify the installed version:

htop --version
htop 3.3.0

The output shows your installed htop version. For reference, Ubuntu 20.04 includes htop 2.2.0, Ubuntu 22.04 ships 3.0.5, and Ubuntu 24.04 provides 3.3.0. Regardless of the specific version, any 3.x release includes all features covered in this guide.

Install htop with Snap

Alternatively, the Snap version delivers newer htop releases directly from the upstream maintainer. Since Ubuntu includes Snap by default, you can install immediately:

sudo snap install htop

Next, verify the Snap installation:

snap list htop
Name  Version  Rev   Tracking       Publisher
htop  3.3.0    3524  latest/stable  maxiberta✪

The Snap version runs in a confined environment with limited system access by default. To enable full system monitoring capabilities, connect optional interfaces: sudo snap connect htop:mount-observe and sudo snap connect htop:network-control for advanced network statistics.

Use htop to Monitor and Control Processes

Htop uses function keys and arrow keys to navigate, sort, and control processes. Additionally, the interface supports both keyboard shortcuts and mouse interaction. For quick reference, press F1 inside htop anytime to access the built-in help screen.

Launch htop

Start htop from any terminal:

htop

Furthermore, you can launch htop with filters applied. To monitor only your processes, use:

htop -u $USER

Interactive htop interface displaying system metrics:

The top section displays CPU cores, memory usage, swap usage, and system load averages. Below that, the process list shows PIDs, users, CPU/memory consumption, and command details. You can navigate with arrow keys or click processes with your mouse.

Navigate and Sort Processes

Use arrow keys and function keys to navigate the process list and change sort order:

KeyAction
Up/DownMove through the process list
Left/RightScroll columns to view additional metrics
F6Open sort menu to choose CPU, memory, PID, or other columns
F5Toggle tree view to show parent-child process relationships

Click any column header with your mouse to sort by that metric, or use F6 for keyboard-only navigation.

Kill and Reprioritize Processes

Control misbehaving or resource-intensive applications directly from htop:

  • F9: Send a signal to the selected process. Press F9, then choose SIGTERM (15) to gracefully terminate a frozen application, SIGKILL (9) to force immediate termination if the process refuses to close, or SIGHUP (1) to reload configuration without restarting. Use SIGTERM first when an application freezes and stops responding to normal close buttons.
  • F7/F8: Increase or decrease the selected process’s priority (nice value). Lower values indicate higher priority, while higher values indicate lower priority. Use F8 to reduce priority for background tasks that you want to run slower, preventing them from interfering with interactive applications.

Search and Filter Processes

Quickly locate specific processes with search and filter functions:

  • F3: Search for a process by name. Enter the process name and press Enter to highlight the matching process in the list.
  • F4: Filter the process list to show only processes matching your criteria. Press F4, type your username to see only your processes, or enter an application name to isolate specific programs.

Customize htop Display

Tailor the htop interface to your preferences:

  • F2: Access the setup menu to customize meters, color schemes, and column layouts. Changes save automatically to ~/.config/htop/htoprc.

Your htop configuration persists across sessions. For example, common customizations include adding new meters (network I/O, disk I/O), changing sort columns, and adjusting update intervals.

The htop setup menu for customizing display options:

Exit htop

Press F10 or Q to exit htop.

With basic navigation mastered, you can leverage htop’s advanced features for more specialized monitoring tasks.

htop Command-Line Options

Beyond basic monitoring, htop supports command-line flags for targeted monitoring and scripted workflows.

Monitor Specific Processes

Track specific process IDs without distraction from other system activity:

htop -p 1234,5678,91011

Replace the numbers with actual PIDs you want to monitor. As a result, htop narrows the display to only those processes, which is useful when debugging specific applications.

Adjust Update Frequency

By default, htop refreshes every second. Reduce CPU overhead on resource-constrained systems by slowing the update rate:

htop -d 30

The -d flag sets the delay in tenths of seconds. In this case, the example updates every 3 seconds instead of every second.

Use htop in Scripts

Run htop non-interactively to capture process snapshots:

htop --no-mouse --readonly -n 1

The --readonly flag prevents accidental process modifications, while -n 1 (or --max-iterations=1) exits after one iteration. You can then combine these flags with output redirection for automated monitoring scripts.

Uninstall htop

Uninstall htop using the same method you used for installation.

Uninstall htop (APT)

If you installed htop via APT:

sudo apt remove htop

Alternatively, to completely remove htop along with its system-wide configuration files:

sudo apt purge htop

Uninstall htop (Snap)

If you installed htop via Snap:

sudo snap remove htop

User-specific htop settings are stored in ~/.config/htop/htoprc and persist after uninstallation. Remove this directory manually if you want to clear customized color schemes, column layouts, or meter configurations.

Troubleshooting Common Issues

Most htop installations complete without issues, but the following solutions address common problems.

Package Not Found Error

If APT reports that htop is unavailable, your package cache may be outdated:

E: Unable to locate package htop

To resolve this, update the package cache and retry:

sudo apt update
sudo apt install htop

Then verify the installation succeeded:

htop --version

Terminal Display Issues

If htop displays garbled characters or incorrect colors, your terminal may lack proper Unicode or 256-color support. Test with the no-color mode:

htop --no-color

If monochrome mode works correctly, consider switching to a modern terminal emulator that supports full UTF-8 and color rendering. Meanwhile, check your current terminal capabilities:

echo $TERM

Modern terminals should report xterm-256color or similar. However, if your terminal reports xterm or linux, consider upgrading to a terminal like GNOME Terminal, Konsole, or Terminator.

Permission Denied When Changing Process Priority

Regular users can only adjust nice values for their own processes within restricted ranges. To modify system processes or increase priority (lower nice values), run htop with elevated privileges:

sudo htop

Afterward, verify you can adjust priority by selecting a process and pressing F7 or F8. The nice value should now change without permission errors.

Incorrect CPU Count on Virtual Machines

Virtual machines sometimes report incorrect CPU topology in htop. If you see more cores than your VM actually has, this reflects the host’s physical CPU configuration rather than your VM’s allocation. Nevertheless, the CPU usage percentages remain accurate even if the core count appears wrong.

Slow Process List Updates

If htop feels sluggish or lags behind actual system activity, increase the update frequency:

htop -d 5

This updates every 0.5 seconds instead of the default 1 second. Keep in mind that you should watch the CPU meter in htop itself. If the update frequency causes noticeable CPU spikes, increase the delay value. Since faster updates consume more resources, only use this setting when you need real-time precision for troubleshooting.

Closing Thoughts

You now have htop installed and can identify resource-hungry processes, terminate frozen applications with F9, and filter by user or application name with F4. Press F2 to customize meters and save your preferred layout. For remote server monitoring, install SSH on Ubuntu and run htop over secure connections to diagnose performance issues from anywhere.

Leave a Comment