What is htop?
If you have ever used the Windows Task Manager, then you will feel right at home with htop. It is an interactive system-monitor process-viewer and process-manager designed for Unix systems.
While most Linux distributions come pre-installed with the standard top command, htop provides a much more user-friendly, colourful, and interactive environment. It allows you to scroll vertically and horizontally, meaning you can see all processes running on the system along with their full command lines.
How to Install htop
Installing htop is incredibly straightforward. Simply open your terminal and run the command corresponding to your Linux distribution.
For Ubuntu and Debian-based systems:
sudo apt update
sudo apt install htop
For CentOS, RHEL, and Fedora:
sudo dnf install htop
How to Use htop
Once installed, you can launch the application by simply typing htop into your terminal and hitting Enter.
htop
You will be greeted with a split screen. The top half displays a summary of your system’s resources, including:
- CPU Usage: Visualised with bars for each of your CPU cores.
- Memory (RAM): Shows how much of your total RAM is currently in use.
- Swap: Displays the usage of your swap space.
- Tasks & Load Average: Summarises the number of running tasks and the system load over 1, 5, and 15 minutes.
The bottom half of the screen displays the actual list of running processes, similar to the top command but with interactive capabilities.
Essential htop Keyboard Shortcuts
The true power of htop lies in its interactive shortcuts. Here are the most useful commands to manage your system’s resources:
- F3 (Search): Allows you to search for a specific process by its name.
- F4 (Filter): Filters the process list to only show processes matching your keyword.
- F5 (Tree View): Organises processes into a parent-child tree hierarchy, making it easy to see which application spawned which process.
- F6 (Sort): Lets you sort the processes by a specific column, such as CPU%, MEM%, or Time.
- F9 (Kill): Sends a signal to terminate the currently selected process. It will prompt you to choose the termination signal (SIGTERM is default).
- F10 (Quit): Exits the
htopapplication and returns you to the terminal prompt.
Conclusion
Monitoring your Linux system doesn’t have to be a chore. By using htop, you gain a visually appealing and highly interactive way to manage your system’s resources directly from the command line.