A Beginners Guide to htop for Process Management

Are you using memory-intensive processes? Do you need to closely monitor containers and virtual systems on your computer? htop is the tool you’ve been looking for.

Its color-coded display makes it easy to understand the status of your system at a glance and gives you the power to manage processes with a single keystroke.

What is htop?

htop is a text-mode (console or terminal) process application for Unix systems. It plays three primary roles:

  1. System monitor.
  2. Process-viewer.
  3. Process manager.

htop is interactive via mouse and keyboard. It has bright colors that aid in giving quick, visual, at-a-glance information about your system’s status. Tasks like finding and killing pesky processes can be easily performed without entering their PIDs, and the list of processes can be quickly sorted and filtered.

I rely on htop for the information I need to know how well my computer and docker containers are running. It makes it super easy to closely monitor resource-hungry processes and ensure that they don’t get out of hand.

How to Use htop

Setup

To get started using htop, install it by running the following command:

  • Linux: sudo apt-get install htop
  • Mac: brew install htop

Then, run the command htop.

I’ll walk you through the critical parts of the interface.

CPU and Memory Usage

At the very top, there are multiple numbered bars with colorful | ticks. Each bar represents a CPU core, and the colorful ticks inside the bar represent the load on that core.

The number of bars depends on the number of cores your CPU has. For example, if your computer has 8 cores, there will be 8 bars. The colors represent the type of process running on that core:

  • Blue: low priority processes.
  • Green: normal (user) processes.
  • Red: kernel processes.

Below the CPU bars are the memory (Mem) and swap (Swp) rows. Just like the CPU, these rows have colorful ticks that represent the amount of memory being consumed by processes running on the computer. Their colors represents the following:

  • Green: used memory pages.
  • Blue: buffer pages.
  • Yellow: cache pages.

Tasks, System Load Averages, and Uptime

Next to the memory bars, there is a section that shows the system tasks, load average, and uptime:

  • Tasks are the number of open processes on the system. There are three values shown: the total number of tasks (processes) on the machine, the number of threads those tasks are broken up into, and the number of tasks currently running.
  • Load average is a measure of the computational work performed by the CPU. A single-core CPU with 100% utilization has a 1.0 load average. A quad-core CPU with 100% utilization has a 4.0 load average. There are three load average numbers listed, representing the one-minute average, five-minute average, and fifteen-minute average.
  • Uptime is the total system uptime since its last reboot.

Process Information

htop provides a list containing all the running processes on the system being monitored. Each column on the header represents the following:

  • PID: process ID number.
  • USER: process owner.
  • PRI: process priority by the kernel.
  • NI: process priority reset by the user or root.
  • VIR: virtual memory the process is consuming.
  • RES: physical memory the process is consuming.
  • SHR: shared memory that the process is consuming.
  • S: current process state.
  • CPU%: percentage of CPU that the process is consuming.
  • MEM%: percentage of memory that the process is consuming.
  • TIME+: time measured in clock ticks since process execution started.
  • Command: name of the command that started the process

The footer contains basic menu commands. Some key ones include:

  • F2 to tweak features.
  • F3 for searching processes.
  • F4 for filtering processes.
  • F5 shows a process tree.
  • F6 sorts processes by specific columns.
  • F9 kills the highlighted process.

Useful Shortcut Keys

To truly become a master at using htop, be sure to use these handy shortcuts.

  • u: displays all processes owned by a particular user.
  • p: sort processes on high CPU consumption.
  • m: sort processes on high memory consumption.
  • t: sort process on time.
  • Space: tag a process
  • c: tag a process and child processes
  • Shift + u: remove all tags.
  • Shift + f: highlight and follow a process.
  • Shift + h: show/hide user and kernel processes.
  • a: set what CPU cores a process can access.
  • i: set IO priority.
  • h: help menu.

Conclusion

If you are looking for an easy-to-use process manager, there is no question that htop is the best. Hopefully, this beginner’s guide helped you understand htop and utilize it to its full potential.