CentOS / RHEL Install htop Process Viewer

last updated in Categories , , , ,

I am a new Linux/CentOS/RHEL sysadmin. How do I install an interactive text-mode process viewer called htop on CentOS/RHEL (Red Hat Enterprise Linux) 5.x/6.x/7.x based system using yum command command?

htop is nothing but Interactive process viewer for CentOS/RHEL based servers and desktop systems. It is just like default top command with an additional set of options and better display on the screen. This page shows how to install htop on CentOS/RHEL using yum command line options.

CentOS / RHEL Install htop command

You can install htop on CentOS/RHEL/Fedora Linux using EPEL repo. From the man page:

Htop is a free (GPL) ncurses-based process viewer for Linux. It is similar to top, but allows you to scroll vertically and horizontally, so you can see all the processes running on the system, along with their full command lines. Tasks related to processes (killing, renicing) can be done without entering their PIDs.

The procedure for installing htop on CentOS/RHEL is as follows:

  1. Open the terminal window.
  2. For remote CentOS/RHEL server login using ssh command.
  3. Execute yum search htop command to search for htop on CentOS/RHEL
  4. Run sudo yum install htop to install htop in CentOS/RHEL

Let us see all commands and examples.

Install htop on CentOS/RHEL/Red hat Linux using yum

First you need to enable EPEL repo as described here to install atop. Type the following yum command:
# yum install htop
Sample outputs:

Loaded plugins: auto-update-debuginfo, protectbase, rhnplugin, security
This system is receiving updates from RHN Classic or RHN Satellite.
0 packages excluded due to repository protections
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package htop.x86_64 0:1.0.1-2.el6 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
============================================================================================
 Package            Arch                 Version                   Repository          Size
============================================================================================
Installing:
 htop               x86_64               1.0.1-2.el6               epel                75 k
 
Transaction Summary
============================================================================================
Install       1 Package(s)
 
Total download size: 75 k
Installed size: 161 k
Is this ok [y/N]: y
Downloading Packages:
htop-1.0.1-2.el6.x86_64.rpm                                          |  75 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : htop-1.0.1-2.el6.x86_64                                                  1/1 
  Verifying  : htop-1.0.1-2.el6.x86_64                                                  1/1 
 
Installed:
  htop.x86_64 0:1.0.1-2.el6                                                                 
 
Complete!

How do I use htop program?

Type the following command as root user. The basic syntax is:
# htop
# htop [options]

Sample outputs:

CentOS / RHEL Install htop and use it
Fig.01: htop in action

htop command examples

Here are some conman and useful examples of htop commands:

Delay between data updates, in tenths of seconds

# htop -d 5
# htop --delay=10

How to start htop in monochrome mode i.e. disable colors

# htop -C
# htop --no-color
# htop --no-colour

Show only the process of a given user (say nixcraft or apache user)

# htop -u nixcraft
# htop --user=apache

Display working thread for pagemap memory stats

# htop -p

CentOS/RHEL htop keyboard shortcut keys

The following commands are supported while in htop:

CommandDescription
Up arrow keySelect (highlight) the previous process in the process list. Scroll the list if necessary.
Down arrow keySelect (highlight) the next process in the process list. Scroll the list if necessary.
Left arrow keyScroll the process list left.
Right arrow keyScroll the process list right.
PgUp, PgDnScroll the process list up or down one window.
HomeScroll to the top of the process list and select the first process.
EndScroll to the bottom of the process list and select the last process.
sTrace process system calls: if strace(1) is installed, pressing this key will attach it to the currently selected process, presenting a live update of system calls issued by the process.
lDisplay open files for a process: if lsof(1) is installed, pressing this key will display the list of file descriptors opened by the process.

Other keyboard shortcuts

uShow only processes owned by a specified user.
MSort by memory usage (top compatibility key).
PSort by processor usage (top compatibility key).
TSort by time (top compatibility key).
F“Follow” process: if the sort order causes the currently selected process to move in the list, make the selection bar follow it. This is useful for monitoring a process: this way, you can keep a process always visible on screen. When a movement key is used, “follow” loses effect.
KHide kernel threads: prevent the threads belonging the kernel to be displayed in the process list. (This is a toggle key.)
HHide user threads: on systems that represent them differently than ordinary processes (such as recent NPTL-based systems), this can hide threads from userspace processes in the process list. (This is a toggle key.)
pShow full paths to running programs, where applicable. (This is a toggle key.)
Ctrl-LRfresh the screen.
F1See this help menu.

Conclusion

This page showed you how to install and use htop on CentOS/RHEL based Linux server. It has many more option. Hence, see the htop home page online here or read htop(1) command man page for more information.

This entry is 8 of 10 in the htop Tutorial series. Keep reading the rest of the series:
  1. OpenBSD install htop
  2. FreeBSD install htop
  3. Ubuntu Linux install htop
  4. RHEL 8 install htop
  5. macOS install htop
  6. Alpine Linux install htop
  7. pfSense install htop
  8. CentOS/RHEL: Install htop An Interactive Text-mode Process Viewer
  9. Amazon Linux AMI nstall htop
  10. Install htop on CentOS 8

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Start the discussion at www.nixcraft.com

Historical Comment Archive

1 comment

    Still, have a question? Get help on our forum!