How to install htop on CentOS Linux 8

last updated in Categories ,

I am a new user of CentOS Linux 8 operating system. How do I install htop on CentOS 8 using the yum command?

htop is nothing but an interactive process viewer for CentOS Linux 8 system. It is just like default top command with an additional set of options and better display on the monitor. This page shows how to install htop on CentOS 8 using command line options.

How to install htop on CentOS 8 using yum

The procedure for installing htop CentOS Linux 8 is as follows:

  1. Open the terminal window.
  2. For remote CentOS 8 server login using ssh command.
  3. Turn on EPEL repo
  4. Execute sudo yum search htop command to search for htop on CentOS
  5. Run sudo yum install htop to install htop in CentOS 8
  6. Update sudo yum update htop to upgrade htop to the latest version in CentOS 8

Let us see all steps and examples in details.

Turn on EPEL repo on CentOS 8

Make sure EPEL repo enabled and installed. If not, run:
vivek@centos8-box:$ sudo yum -y install epel-release
vivek@centos8-box:$ sudo yum repolist

Please note that vivek@centos8-box:$ is my shell prompt. You need to type all commands after that prompt.

CentOS Linux 8 install htop

It is important that you know how to search for any packages. Therefore type the following command to search for htop package using yum command:
vivek@centos8-box:$ sudo yum search htop
Sample outputs:

Last metadata expiration check: 0:05:46 ago on Fri Nov 22 19:26:05 2019.
======================== Name Exactly Matched: htop =========================
htop.x86_64 : Interactive process viewer

Find information about htop package

Run the following command:
vivek@centos8-box:$ sudo yum info htop
Sample outputs:

Last metadata expiration check: 0:06:33 ago on Fri Nov 22 19:26:05 2019.
Available Packages
Name         : htop
Version      : 2.2.0
Release      : 6.el8
Arch         : x86_64
Size         : 112 k
Source       : htop-2.2.0-6.el8.src.rpm
Repo         : epel
Summary      : Interactive process viewer
URL          : http://hisham.hm/htop/
License      : GPLv2+
Description  : htop is an interactive text-mode process viewer for Linux,
             : similar to top(1).

Installing htop on CentOS 8

First, make sure you system is up to date:
vivek@centos8-box:$ sudo yum update
vivek@centos8-box:$ sudo yum upgrade

Finally, run the following to install htop on CentOS:
vivek@centos8-box:$ sudo yum install htop

Installing htop on CentOS 8 Linux server using yum
Installing htop on CentOS Enterprise Linux 8 server

How to use htop command

The syntax is:
htop
htop [options]
htop [options] arg

Running htop on CentOS 8 Linux server
Press F10 or q to quit htop session.

One can use a monochrome color scheme, run:

vivek@centos8-box:$ htop -C
vivek@centos8-box:$ htop --no-color

Want to see the tree view by default when running htop? Try:

vivek@centos8-box:$ htop -t
vivek@centos8-box:$ htop --tree

Let us see only processes of a given user named vivek:
vivek@centos8-box:$ htop -u vivek
vivek@centos8-box:$ htop --user=vivek
vivek@centos8-box:$ htop --user=nginx

Limit and show process for only the given PIDs:
vivek@centos8-box:$ htop -p PID
vivek@centos8-box:$ htop -p PID1,PID2
vivek@centos8-box:$ htop --pid=PID,[,PID,PID...]
vivek@centos8-box:$ htop -p 1992
vivek@centos8-box:$ htop -p 1244,2233

CentOS 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.

How to get help about htop

Simply pass the --help option. For example:
vivek@centos8-box:$ htop --help
vivek@centos8-box:$ man htop

Optional: Linux hide processes when using htop

Set up hidepid=2 option as described here:
$ sudo mount -o remount,rw,nosuid,nodev,noexec,relatime,hidepid=2 /proc
$ htop

Conclusion

This page showed you how to install and use htop on CentOS Unix server. It has many more option. Hence, see the htop home page online here or read man page.

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