Monitor Linux System Performance with top and htop

When managing Linux servers, especially on Redhat based systems as RHEL, Rocky Linux or any distribution of Linux realtime monitoring tools like top and htop are handy. They provide a glance of your system health as CPU usage, memory consumption, process details and more.

 In this post, we'll walk you through requirements, installation and usage of both top and htop on Linux systems.

Requirements

                A Linux based system (RHEL, Alma Linux, and Rocky Linux or any Linux distribution)

                Access to terminal (CLI)

                Sudo privileges

Installation:

Mostly top is pre-installed on all Linux distributions. You can run it directly by typing top on bash.

#top

If htop is not pre-installed on any Linux distribution, you can easily install it. As is the case htop is not installed on RHEL 9. Now follow the following steps to install htop in RHEL 9.

Step 1 enable EPEL repository if already not enabled

Here epel repository is enabled by this command on RHEL 9.

Now install epel-release with command sudo dnf install epel-release.

#sudo dnf install epel-release

Step 2 install htop

# sudo dnf install htop


That’s it. Now htop is ready to use.

Usage

To start monitoring issue top command on bash.

# top

This is the interface of top command with real time statistics of the Linux system.

You’ll see realtime statistics. Here's what each section mean:

·       Load average: System load over 1, 5 and 15 minutes

·       Up Time: shows the up time of system

·       Total Task: show the total task

·       Seeping Task: show any sleeping process

·       Zombie Task: show any zombie process

·       Stopped Task: show any of stopped process

·       Running Task: number of running Task

·       Tasks: Number of running, sleeping and stopped processes

·       %CPU: CPU usage per process

·       %MEM: Memory usage per process

·       Swap Memory: usage of swap memory


Common commands within top:

You can run command during top running interface to control the things in real time like the following commands.

q: Quit

k: Kill a process (you'll be prompted for PID)

r: Renice a process (change priority)

h: Help

Using htop

To start monitoring with htop issue htop command on bash.

# htop

You'll get a colorful, interactive dashboard.

Features:

    Scroll with arrow keys

    Use F3 for search and F4 for filter

    F9 kills process and F6 changes sort column

Comparison between top and htop

top

·       By default installed almost in all distributions

·       Provides basic system information and list processes sorted by CPU or memory usage

·       Offers less command-line options for filtering and sorting

·       Comparatively simple to use for basic monitoring

htop

·       Installation is required before to use

·       Includes colored output, supports mouse input and easy process management

·       Interactive interface with visually more appealing

·       Offers robust customized options sorting and display

·       Require more deeper learning curve due to its advance features

Key Differences


Feature

top

htop

Default installation

Yes

No

User interface

Basic text-based

Enhanced, interactive, color-coded

Mouse support

No

Yes

Process management

Limited

More intuitive, including killing/renicing

Customization

Basic

Extensive

Learning curve

Low

Moderate

Final Thoughts:

Both top and htop is essential tools in a Linux admin's toolbox. While top is always available and reliable, htop brings user-friendly enhancements that makes system monitoring much more interactive.  You are diagnosing system performance issues or monitoring your system load, mastering these tools will give you a deep understanding of what is happening under the hood.

keep visiting seeklinux for more updates and information.

Post a Comment