How to use htop command to monitor system processes in real-time

The htop command in Linux is a command-line utility that enables users to interactively monitor important system processes in real-time.

In today’s Terminal Tuts, we are going to present yet another powerful system process monitoring command ‘htop’, which in Linux is a command-line utility that enables users to interactively monitor important system processes in real-time.

The command was developed by Hisham Muhammad 15 years ago as a replacement for its older brother, top, and was released in May 2004. Yet many Linux users are still not aware of the powerful utility nor its usefulness as a system monitor and process viewer.

The top Command In Action
The top Command In Action

The top has been a mainstay in the Unix/Linux community since 1984 (over 35 years),  But, in this Linux user’s opinion, has overstayed its welcome.  htop is the new kid on the block, and it is powerful.

htop command advantages

You can interactively monitor your system’s vital resources or processes in real-time.  The color used in its output makes it much more comfortable to read than does the monochrome top output.

The only benefit I can see in using top is that it is older and thus more tested and tried.  But, I am more than comfortable with the stability of a 15-year-old Linux utility.

  • supports mouse operation
  • allows you to scroll both horizontally and vertically, allowing you to see all processes and complete command lines
  • allows you to kill a process without knowing the PID (in top, you must specify the PID).
  • starts faster, while top seems to delay a bit while collecting data.
  • top requires you to type the PID or priority value to alter the scheduling priority or renice a process, while the latter does not

HTOP In Action
HTOP In Action

htop command usage

The command is easy to invoke from the command prompt:

# htop

The command usage is divided into three parts.

In the first part (upper-left corner), we see bar-like gauges that show our processor usage, memory in use, and swap memory in use, respectively.

The second part (upper-right corner) shows us standard information, such as a task summary, load average, and uptime.

The last section is the bottom where you will see 12 columns.  They are:

  • PID – process ID
  • USER – username of the process owner (or user ID if the name can’t be determined)
  • PRI – internal priority of the kernel for the process
  • NI – nice value of a process — from low priority, 19 to high priority, -20
  • VIRT – size in memory of total program size
  • RES – resident set size
  • SHR – size of the process’s shared pages
  • S – state of the process (S – sleeping/idle, R – running, D – disk sleep, Z – zombie, T – traced/suspended)
  • W – paging
  • CPU% – percentage of CPU time process is currently using
  • MEM% – percentage of memory process is currently using
  • TIME+ – time (measured in clock ticks process has spent in user and system time)
  • Command – full path of the command

As with most Linux commands, there are options too.

# htop [-dChusv]
  • d – delay (shows the delay between updates (in tenths of seconds))
  • C – no-color (monochrome mode)
  • h – help (display the help message and exit)
  • u – user=USERNAME (show only the processes of a given user)
  • h – pid=PID, (show only the given PIDs)
  • s – sort-key COLUMN (Sort by this column)
  • v – version (output version information and exit)

htop - root processes only
– root processes only

You can also use the interactive commands you can use while the command is running to change the sort/look of your window.  These are:

  • Arrows, Page Up, Page Down, Home, End– scroll the process list
  • Space – tag or untag a process
  • U – untag all processes
  • s – trace process system calls
  • F1 – Help
  • F2 – setup
  • F3 – search
  • F4 – filter
  • F5 – tree view
  • F6 – sort
  • F7 – increase the selected process’s priority
  • F8 – decrease the selected process’s priority
  • F9 – kill process
  • F10 – quit <Esc> also works

sorted by time

One can also sort the columns simply by using the mouse, too.

htop -u in Action
-u in Action

This wonderful command not only proven instrumental in helping me locate memory leak issues over the years, but also helped me find recently installed programs that are hogging my CPU.

We encourage both new and experienced Linux users alike to use the man command to view all the features that the command provides.

# man htop

man page

Not only is the command an invaluable utility for the veteran Linux user’s toolkit, but it is also useful for the new Linux user to gain a better understanding of how Linux works and discover “what’s under the hood.”

Similar utilities that I have used in troubleshooting include both atop and glances.  Look forward to future articles on those utilities soon.

Glances in Action
Glances in Action

There is so much more to explore with this tool then what I’ve included in this article.  Please give it a try.  You’ll be glad you did.

Travis Rose
Hi, I'm M Travis Rose, a contributor to FOSS Linux. I have over thirty years of experience in the IT arena, at least fifteen of which has been working with Linux. I enjoy converting existing Windows users to the wonderful world of Linux. I guess you could call me a Linux-evangelist. Long live Linux!

LEAVE A REPLY

Please enter your comment!
Please enter your name here

STAY CONNECTED

23,662FansLike
359FollowersFollow
16SubscribersSubscribe

LATEST ARTICLES

How to install Lightworks on Ubuntu

Even though Linux may not get a native installer of video editing software like Adobe Premiere or Final Cut Pro, that doesn't mean there are no industry standards tools available. Lightworks is non-linear editing (NLE) video mastering app for Windows, Linux, and macOS. Installing it on Ubuntu is simple due to deb package availability.

How to install DaVinci Resolve on Fedora

Davinci Resolve is a professional application used for color correction, video editing, visual effects, and motion graphics. It is one of the extensively used software by movie industries located in Hollywood.

The 10 Best Programming Languages for Hacking

One of the significant entities we have in Cyber Security is Ethical Hacking (ETH). It is the process of detecting and finding flaws or vulnerabilities in a system that a hacker would exploit.

5 Ways to Open a Terminal in Ubuntu

Even though Ubuntu supports many applications with amazing Graphical User Interfaces (GUI), there are always reasons why users prefer using the Terminal to perform different tasks.

How to install Wine on Fedora Workstation

Linux distributions are becoming more and more popular every day, and Fedora Workstation is not left behind. This popularity brings forth the need to run Windows applications on Linux distros like Fedora. Windows has quite some excellent Software that is not available for Linux.

How to download and install iTunes on Linux

iTunes has always been a convenient platform for downloading, organizing, playing, and syncing media between your Apple devices. It also gives users a large pool of media to buy or stream millions of songs using Apple Music.

MUST READ

Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.
Elementary OS 5.1 Hera has received a point release with a handful of new features and bug fixes, and we will be reviewing the significant changes in this article. For those new to elementary OS, this Ubuntu-based Linux distribution uses their inhouse built Pantheon desktop environment and AppCenter.

Linux Mint vs. Ubuntu – which is best for you?

The conundrum is that which one among them? The best solution is to try both of them out, and then choose whatever seems to work the best for your needs. But here, we're giving you some distinctions between the both that might make it easier for you to make a choice.

Pop!_OS 20.04 Review: Professional Linux Distribution Ever Made

Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.

15 Tar command in Linux uses with examples

Tar is a famous utility that is basically used for collecting multiple files in a single archive. This file is often called a 'tarball'. Today, we are going to tell you about the different things you can do with tarballs using the tar command, with practical examples.

VIDEO: Linux Lite 4.8 Features and Desktop Tour

Linux Lite eases Windows 7 users transition to Linux much more comfortable by offering simple software like Team Viewer, VLC, Firefox, TimeShift backup utility, and a full Microsoft Office compatible office suite in LibreOffice.