Home > Process Management > htop

htop Command Guide: Enhanced Interactive Process Viewer

`htop` is an interactive process viewer used for monitoring running processes and system resource usage in real-time on Linux systems. It provides a much more user-friendly interface and powerful features compared to the traditional `top` command, making it a widely recommended tool for system performance analysis and troubleshooting. In this guide, you will learn how to install `htop`, its key features, and how to use it effectively.

Installing htop

`htop` may not be pre-installed on most Linux distributions. Here are the installation methods for major operating systems.

Installing htop on Linux

You can install `htop` using the package manager of each distribution.

Install htop on Debian/Ubuntu

sudo apt update
sudo apt install htop

Install `htop` using the APT package manager.

Install htop on Fedora/CentOS/RHEL

sudo yum install htop  # CentOS/RHEL 7 and below
sudo dnf install htop  # Fedora/CentOS/RHEL 8 and above

Install `htop` using YUM or DNF package manager.

Overview of htop

`htop` includes all the features of `top` while greatly enhancing visual improvements and ease of use. Major features include color-coded output, mouse support, easy sorting and filtering, and direct actions on processes (termination, priority change). It excels at intuitively understanding the CPU, memory, and swap usage of the system and managing individual processes in detail.

Main Functions of htop

`htop` is primarily used for the following purposes:

Key Usage Areas

  • Real-time system monitoring: Visually displays system resource usage rates, including CPU, memory, swap, and network activity.
  • Detailed process analysis: Easily checks detailed information about each process, such as CPU and memory usage, PID, user, and command.
  • Performance bottleneck diagnosis: Quickly identifies excessive use of specific processes or resources to pinpoint the causes of system performance degradation.
  • Process management: Uses mouse or keyboard shortcuts within the `htop` interface to terminate processes or change their priority.

htop vs top

`htop` is an intuitive improvement over `top`, offering several advantages including:

Advantages of htop

  • User interface: Color-coded CPU/memory graphs and clearer information display.
  • Mouse support: Allows sorting criteria changes, process selection, and action execution via mouse clicks.
  • Easy scrolling: Allows easy viewing of lengthy or wide process information through horizontal scrolling.
  • Process tree view: Visualizes the parent-child relationships between processes in a tree structure.
  • Filtering and searching: Allows easy searching and filtering of specific processes by name or user.
  • Process control: Easily controls processes using function keys such as F9 (kill), F7/F8 (nice).

htop Command Options and Interactions

`htop` allows simple command-line options at startup and offers various function keys and mouse operations during execution for convenient system monitoring and management.

1. Command Line Startup Options

2. Interactions During htop Execution (Function Keys and Mouse)

Generated command:

Try combining the commands.

Description:

`htop` Executes the command.

Combine the above options to virtually execute commands with AI.

Usage Examples

Learn how to monitor system resource usage in real-time and diagnose problems through various usage examples of the `htop` command.

Run htop (Basic)

htop

The most basic execution of `htop`, which shows the current state of the system and the process list interactively.

View Only Specific User's (nginx) Processes

htop -u nginx

Useful for monitoring resources used by the Nginx web server.

Find Processes with High CPU Usage (While Running)

htop # Press F6, select PERCENT_CPU, then Enter

After running `htop`, press `F6` and select `PERCENT_CPU` to sort processes by highest CPU usage.

Search by Specific Process Name (While Running)

htop # Press F3, type 'mysql', then Enter

After running `htop`, press `F3` and enter a search term like 'mysql' to highlight processes containing that string.

View Process Tree (While Running)

htop # Press F5

After running `htop`, press `F5` to switch the process list to a tree structure showing parent-child relationships.

Terminate a Process (While Running)

htop # Select a process, then press F9

Select the process you want to terminate (using the arrow keys or mouse) and press `F9` to bring up the signal list, then choose the desired signal (e.g., `SIGTERM` 15, `SIGKILL` 9) to terminate it.


Same category commands