X
    Categories: Linux

Awesome way to improve process monitoring: Install htop Linux on RHEL, Ubuntu and fedora.


If you are a regular Linux user or sysadmin you must be using top utility for process monitoring. Which is a simple utility , If you are bored with top utility. There is a colourful yet interactive utility in Linux, called as “htop”. This post will quickly guide you about how to install htop Linux and perform process monitoring using htop Linux.


Htop is an interactive real-time process monitoring utility or command for Linux.

It’s very similar to native top utility in Linux however with htop utility you can move or scroll horizontally or vertically to capture all the details about the process.

Features of htop linux utlity:

  1. It’s an colourful utility meaning that, it displays data by indicating colour. E.g. If the CPU utilisation is high then it displays Red colour as below:
  2. Highly interactive: It can be handled using keyboard as well as mouse.
  3. Process sorting: You can sort the processes based on cpu or memory utilisation.
  4. Help Menu: You can take advantage of help menu within this utility for carrying out different tasks.

Htop linux installation:

Before proceeding with htop installation we need to install EPEL repository on the system. Below are the commands for the same.

For 32 Bit htop installation:

RHEL 6 & CentOS 6 
# wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -ihv epel-release-6-8.noarch.rpm
For RHEL 5 , Fedora and CentOS 5
# wget http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm 
# rpm -ihv epel-release-5-4.noarch.rpm

For 64 Bit htop installation:

For RHEL 5 , Fedora and CentOS 5
# wget http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
# rpm -ihv epel-release-5-4.noarch.rpm

RHEL 6 & CentOS 6 
# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ihv epel-release-6-8.noarch.rpm
RHEL 7 & CentOS 7
# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
# rpm -ihv epel-release-7-9.noarch.rpm

Sample RHEL7 installation:

[root@rhel2 ~]# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
--2017-05-01 00:46:16--  http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
Resolving dl.fedoraproject.org (dl.fedoraproject.org)... 209.132.181.24, 209.132.181.25, 209.132.181.23
Connecting to dl.fedoraproject.org (dl.fedoraproject.org)|209.132.181.24|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14704 (14K) [application/x-rpm]
Saving to: ‘epel-release-7-9.noarch.rpm’

100%[==============================================================================================================================>] 14,704      57.8KB/s   in 0.2s

2017-05-01 00:46:17 (57.8 KB/s) - ‘epel-release-7-9.noarch.rpm’ saved [14704/14704]

[root@rhel2 ~]# rpm -ihv epel-release-7-9.noarch.rpm
warning: epel-release-7-9.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:epel-release-7-9                 ################################# [100%]
[root@rhel2 ~]#

Once you are done with EPEL installation go ahead with htop installation using yum:

# yum install htop

Sample Htop Installation on RHEL7

[root@rhel2 ~]# yum install htop
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
epel/x86_64/metalink                                                                                                                             | 6.1 kB  00:00:00
epel                                                                                                                                             | 4.3 kB  00:00:00
(1/3): epel/x86_64/group_gz                                                                                                                      | 170 kB  00:00:02
(2/3): epel/x86_64/updateinfo                                                                                                                    | 788 kB  00:00:03
(3/3): epel/x86_64/primary_db                                                                                                                    | 4.7 MB  00:00:07
Resolving Dependencies
--> Running transaction check
---> Package htop.x86_64 0:2.0.2-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
 Package                               Arch                                    Version                                      Repository                             Size
========================================================================================================================================================================
Installing:
 htop                                  x86_64                                  2.0.2-1.el7                                  epel                                   98 k

Transaction Summary
========================================================================================================================================================================
Install  1 Package

Total download size: 98 k
Installed size: 207 k
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7Server/epel/packages/htop-2.0.2-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY 74 kB/s |  64 kB  00:00:00 ETA
Public key for htop-2.0.2-1.el7.x86_64.rpm is not installed
htop-2.0.2-1.el7.x86_64.rpm                                                                                                                      |  98 kB  00:00:02
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
 Userid     : "Fedora EPEL (7) <epel@fedoraproject.org>"
 Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
 Package    : epel-release-7-9.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : htop-2.0.2-1.el7.x86_64                                                                                                                              1/1
  Verifying  : htop-2.0.2-1.el7.x86_64                                                                                                                              1/1

Installed:
  htop.x86_64 0:2.0.2-1.el7

Complete!
[root@rhel2 ~]#

For Debian and Ubuntu:

apt-get install htop

Process monitoring using htop linux

To monitoring process simply type htop command on the command prompt.

In the sample htop output above system display information like CPU , Memory  and Swap utilisation. And on the right side it displays Load average and uptime as well.

  • Sorting Process by CPU or Memory utilisation. 

To Sort the processes by CPU or Memory simple hit F6 key and select Percent CPU or Percent Memory and hit enter to see result.

  1. Press F6.
  2. Now select Percent CPU or Percent Memory as per you need and hit Enter.

Now system displays Process sorted by Memory utilisation as below:

To copy the output as text , Press “Shift” button and select the windows text using mouse.

  • Displaying information related specific user:

    Lets say you want to show processes related to root user only then give below command.

    [root@rhel2 ~]# htop -u root
  • To take help on various options Simply hit F1 key and system will show all the options as below:

    htop 2.0.2 - (C) 2004-2016 Hisham Muhammad
    Released under the GNU GPL. See 'man' page for more info.
    
    CPU usage bar: [low-priority/normal/kernel/virtualiz               used%]
    Memory bar:    [used/buffers/cache                            used/total]
    Swap bar:      [used                                          used/total]
    Type and layout of header meters are configurable in the setup screen.
    
     Status: R: running; S: sleeping; T: traced/stopped; Z: zombie; D: disk sleep
     Arrows: scroll process list              Space: tag process
     Digits: incremental PID search               c: tag process and its children
       F3 /: incremental name search              U: untag all processes
       F4 \: incremental name filtering        F9 k: kill process/tagged processes
       F5 t: tree view                         F7 ]: higher priority (root only)
          p: toggle program path               F8 [: lower priority (+ nice)
          u: show processes of a single user      a: set CPU affinity
          H: hide/show user process threads       e: show process environment
          K: hide/show kernel threads             i: set IO priority
          F: cursor follows process               l: list open files with lsof
     F6 + -: expand/collapse tree                 s: trace syscalls with strace
      P M T: sort by CPU%, MEM% or TIME
          I: invert sort order                 F2 S: setup
       F6 >: select sort column                F1 h: show this help screen
    Press any key to return.                  F10 q: 
    

Please check post about different ways of checking top CPU consuming processes.

View Comments (0)

Related Post