How to Install Htop on Ubuntu 22.04 | 20.04

Welcome to the world of htop, an interactive process viewer for Linux and Unix systems that provides a real-time, dynamic, and colorful display of running processes. Unlike traditional process viewers like top, htop offers a more visually appealing and user-friendly interface. In this introduction, we will explore some of the key features and differences between htop and top. Following this guide, you will learn how to install htop on Ubuntu 22.04 Jammy Jellyfish or Ubuntu 20.04 Focal Fossa.

Key Features of htop

  • Visually engaging interface: htop presents system information in a more accessible and colorful format, making it easier to understand and analyze the current state of your system.
  • Easier navigation: With htop, you can easily navigate through the list of processes using arrow keys, eliminating the need for complex commands.
  • Real-time updates: htop updates the process list in real-time, ensuring that you always have the most up-to-date information on your system’s resource usage.

Differences between htop and top

Process Management

  • htop: Supports mouse and keyboard interaction for process management, enabling you to send signals directly to processes by selecting them and pressing appropriate keys.
  • top: Primarily uses command-line options and shortcuts for process management, which can be less intuitive for new users.

Resource Usage Visualization

  • htop: Displays CPU, memory, and swap usage with easy-to-read color-coded bars, offering a more visual understanding of system resources.
  • top: Presents resource usage as percentages and raw numbers, which can be harder to interpret at a glance.

Sorting and Filtering

  • htop: Allows you to sort processes by various criteria (such as CPU usage, memory usage, or process ID) and filter the process list based on user-defined expressions.
  • top: Offers limited sorting options and lacks built-in filtering capabilities.

By the end of this guide, you will have a comprehensive understanding of the advantages of using htop over traditional process viewers like top. The guide will demonstrate how to install htop on Ubuntu 22.04 Jammy Jellyfish or Ubuntu 20.04 Focal Fossa.

Section 1: Install Htop with APT

Step 1: Update System Packages

Before installing Htop, it’s crucial to ensure that all existing packages on your system are up to date. Updating your system packages helps maintain system stability, security, and compatibility with the latest software. To update your system packages, run the following command:

sudo apt update && sudo apt upgrade

This command will refresh the package list and upgrade any outdated packages, providing a solid foundation for the Htop installation.

Step 2: Choose an Installation Method

Method 1: Install Htop from the Ubuntu Repository

The first method for installing Htop involves using the Ubuntu repository. This approach is recommended for new Linux and Ubuntu users, as it prioritizes system stability. However, the version of Htop available in the Ubuntu repository may not be the most recent one, which means you could miss out on the latest features and bug fixes. If you require a more up-to-date version of Htop, consider using the PPA method in Method 2.

To install Htop from the Ubuntu repository, execute the following command:

sudo apt install htop

Once the installation is complete, you can verify the installed version by running the following command:

htop --version

Method 2: Install Htop using a PPA

The second method for installing Htop involves adding the Htop PPA (Personal Package Archive) to your system. This approach is suitable for users who need the most up-to-date version of Htop. The PPA is maintained by Hung-Yi Chen and generally contains the latest version of Htop for LTS (Long-Term Support) versions of Ubuntu.

First, add the Htop PPA to your system by running the following command:

sudo add-apt-repository ppa:gaod/htop -y

Next, update your system’s package list to include the newly added PPA by executing:

sudo apt update

Finally, install Htop using the following command:

sudo apt install htop

Section 2: Getting Started with Htop

Htop is a powerful and interactive process viewer that provides a wealth of information about your system’s processes and resources. In this section, we will explore some common Htop commands, including examples and explanations to help you better understand and utilize this versatile tool.

Step 1: Launch Htop

To start Htop, open a terminal window and enter the following command:

htop

Example of Htop on Ubuntu Linux terminal:

Once launched, Htop will display a live, interactive view of your system’s processes, CPU usage, memory usage, and other essential metrics.

Step 2: Navigate and Sort Processes

Htop provides an easy-to-use interface for navigating and sorting processes. Here are some basic navigation commands:

  • Up/Down Arrow Keys: Navigate through the list of processes.
  • Left/Right Arrow Keys: Switch between different metrics, such as CPU usage, memory usage, and process priority.

To sort processes based on a specific metric, press the corresponding function key:

  • F6: Sort processes by user-defined criteria (e.g., CPU usage, memory usage, process ID).
  • F5: Toggle the process tree view, displaying the parent-child relationship between processes.

Step 3: Manage Processes

Htop allows you to manage processes directly from its interface. Here are some essential process management commands:

  • F9: Send a signal to the selected process (e.g., SIGTERM to terminate the process, SIGHUP to restart the process).
  • F7/F8: Increase or decrease the selected process’s priority (also known as “nice” value). Lower values indicate higher priority, while higher values indicate lower priority.

Step 4: Search and Filter Processes

Htop provides search and filter functionalities to help you quickly locate specific processes:

  • 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 based on user-defined criteria (e.g., process name, user). Enter the filtering criteria and press Enter to display only the matching processes.

Step 5: Customize Htop Display

Htop offers various customization options to tailor the display to your preferences:

  • F2: Access the Htop setup menu, where you can customize the display, colors, and layout.

Step 6: Quit Htop

To exit Htop, press either the F10 key or the Q key.

Example of Setup menu with Htop on Ubuntu Linux terminal:

Section 3: Additional Htop Commands with Ubuntu Linux

In this section, we will explore additional Htop commands for Ubuntu Linux users, including how to uninstall Htop and remove its PPA if you have installed it using the PPA method.

Step 1: Uninstall Htop

If you need to uninstall Htop from your system, the process is simple and straightforward. Follow the steps below to remove Htop from your Ubuntu Linux system.

Step 1.1: Remove Htop Package

Execute the following command in your terminal to uninstall Htop:

sudo apt remove htop

This command will remove the Htop package and its associated files from your system. However, if you have installed Htop using the PPA method, there is one more step to completely remove the PPA.

Step 1.2: Remove Htop PPA (Optional)

If you have installed Htop using the PPA method as described in Section 1, you may also want to remove the PPA from your system. To do this, execute the following command:

sudo add-apt-repository --remove ppa:gaod/htop -y

This command will remove the Htop PPA maintained by Hung-Yi Chen from your system’s list of package repositories, ensuring that it no longer receives updates from this source.

Closing Thoughts on Installing Htop on Ubuntu Linux

In conclusion, installing and utilizing the Htop interactive viewer on Ubuntu Linux is a valuable tool for monitoring system resources and managing processes efficiently. Throughout this article, we have covered the installation process, common Htop commands, and additional information on uninstalling Htop and removing its PPA. Following the steps and guidance provided, you can successfully set up and use Htop on your Ubuntu Linux system, regardless of your experience level.

Additional Resources and Links

To further expand your knowledge and understanding of Htop and Ubuntu Linux, we recommend the following resources:

  • Official Htop Website: Htop GitHub Repository – Visit the official Htop GitHub repository for source code, release notes, and issue tracking.

Share to...