Most engineers open htop when a server feels slow, see a wall of coloured bars, and decide something is "high". Then they restart the wrong service. The screen is dense, but every field has a precise meaning, and once you can read it, htop answers three questions in about ten seconds: is the machine short of CPU, short of memory, or waiting on something else?

This guide walks the screen top to bottom using htop 3.3 on Ubuntu 24.04 with the default colour scheme. Colours and meters can be changed in setup, so when in doubt press F1 (or h): the help screen prints the colour legend for your exact version and theme.

The header: meters, not truth

The top half is a set of meters you can rearrange with F2 (Setup). The default layout shows one bar per CPU, a memory bar, a swap bar, and three text meters: tasks, load average and uptime.

CPU bars

Each numbered bar is one logical CPU, so a 4-core machine with hyper-threading shows eight bars. The bar is split into coloured segments by the type of work the CPU spent its time on since the last refresh:

Colour (default)

Meaning

Blue

Low-priority user processes (positive nice value)

Green

Normal-priority user processes

Red

Kernel time (system calls, drivers, interrupts)

Cyan

Virtualisation steal or guest time

Turn on "Detailed CPU time" in F2, then Display options, and the bar splits further: IRQ, soft-IRQ, IO-wait and steal each get their own colour. On virtual machines this is worth enabling permanently, because steal time is the hypervisor taking cycles from you, and no amount of tuning inside the guest fixes it.

How to read the shape:

  • Mostly green, near 100% on every bar: genuine CPU-bound user work. Find the process with P (sort by CPU).

  • Big red segment: the kernel is busy on your behalf. Common causes are heavy network packet processing, lots of small read/write calls, or a filesystem doing work. strace -c on the hot process tells you which syscalls dominate.

  • One bar pinned, the rest idle: a single-threaded program. Adding cores will not help; making that one thread faster or splitting the work will.

  • Bars low but the machine feels slow: CPU is not your problem. Look at load average and the process state column, covered below.

Memory and swap

The memory bar is where most misreadings happen. In the default scheme green is memory used by processes, blue is kernel buffers, and yellow/orange is page cache. Newer versions also show shared and compressed memory segments; F1 lists them.

The number printed at the right of the bar is used memory excluding buffers and cache. Page cache is file data the kernel keeps in RAM because RAM is otherwise idle. It is handed back the moment a process needs memory, so a bar that is "full" of yellow is a healthy machine using its RAM, not a machine about to run out.

The swap bar matters more than people think. A small, stable amount of swap used is normal: the kernel moved pages nobody touches out of RAM. Swap usage that keeps growing while you watch, together with processes in state D, means you are paging actively, and that is slow.

Tasks, load average and uptime

Tasks: 182, 941 thr, 120 kthr; 3 running reads as 182 processes, 941 user threads, 120 kernel threads, and 3 tasks on a CPU or ready to run at this moment. A very high thread count with low CPU is often a thread pool misconfigured to thousands of threads.

Load average: 3.12 2.40 1.95 is the 1, 5 and 15 minute exponentially damped average of tasks that are runnable or in uninterruptible sleep. Two things to remember:

  1. Divide by the number of CPUs. A load of 3 on an 8-CPU machine is light; on a 2-CPU machine it means tasks queue for CPU most of the time.

  2. On Linux, load includes tasks waiting in uninterruptible sleep (state D), usually disk or network filesystem I/O. A load of 40 with idle CPU bars almost always means many tasks stuck on storage, not too much computation.

Reading the three numbers left to right tells you the trend: 8.0 4.0 1.5 is a problem that started in the last few minutes; 1.5 4.0 8.0 is one that is fading.

The process table, column by column

Column

What it is

Note

PID

Process ID (or thread ID when threads are shown)

USER

Effective user

PRI / NI

Kernel priority / nice value

Nice ranges from -20 (favoured) to 19 (polite)

VIRT

Virtual address space size

Includes mapped files and reserved-but-unused memory; rarely meaningful alone

RES

Resident set size: pages actually in RAM

Shared libraries count in every process that maps them

SHR

The part of RES that is shared

S

State

R running, S sleeping, D uninterruptible, Z zombie, T stopped, I idle kernel thread

CPU%

Share of one CPU since last refresh

350% means three and a half CPUs

MEM%

RES as a share of total RAM

TIME+

Total CPU time consumed, to hundredths of a second

Command

Full command line

p toggles showing the program path

Two misreadings come up constantly. First, a Java or Go service with 30 GB VIRT is not using 30 GB; runtimes reserve address space up front. Watch RES. Second, adding up RES across processes overcounts, because shared pages appear in each one. For a precise per-process figure use PSS from /proc/<pid>/smaps_rollup.

F2, then Columns, lets you add fields such as IO_RATE, IO_READ_RATE, IO_WRITE_RATE (needs root to see other users' processes), OOM (the kernel's OOM score) and CGROUP. On container hosts the cgroup column is the quickest way to map a busy PID back to a container.

Keys that answer real questions

You do not need all of htop's keys. These cover nearly every investigation:

Question

Key

What is using the most CPU?

P sort by CPU%

What is using the most memory?

M sort by MEM%

What has burned the most CPU since it started?

T sort by TIME+

Sort by any other column

F6 or > then pick

Reverse the sort

I

Find a process by name

F3 or / (jumps, keeps others visible)

Show only matching processes

F4 or \ (filter)

Only one user's processes

u

Who started what?

F5 or t tree view

Hide user threads / kernel threads

H / K

Freeze the display to read it

Z (pause updates)

Open files of the selected process

l (runs lsof)

Syscalls of the selected process

s (attaches strace)

Renice / send a signal

F7 F8 / F9 or k

Tag several processes

Space, then act on all tagged

Tree view deserves special mention. A PHP-FPM pool, a Gunicorn master, or a Chrome crawler spawns many children; sorting flat by memory shows dozens of medium entries, while the tree shows one parent owning all of them. When killing, kill the parent and let it clean up, or you will watch the supervisor respawn children forever.

Start htop with options when you already know what you want:

htop -u www-data          # only processes of one user
htop -p 1423,1588         # only these PIDs
htop -d 20                # refresh every 2 seconds (unit is tenths of a second)
htop -t                   # start in tree view
htop --filter=postgres    # start with a filter applied

So what is "high"?

Thresholds without context are how alerts become noise. A practical way to judge each reading:

Reading

Probably fine

Worth investigating

CPU bars

Spiky, average below ~70%

Sustained near 100% on all bars, or high steal on a VM

Red (kernel) share

A few percent

Kernel time rivals user time

Memory

Bar full of cache, available memory comfortable

Green (used) segment near the end and swap growing

Swap

Small and constant

Rising minute by minute

Load per CPU

Below 1

Above 1 for 15 minutes, or load high with idle CPUs

D state processes

Occasional, briefly

Many, for long periods

Zombies

Zero or a few, transient

Hundreds and rising (parent is not reaping)

The last two rows are things htop shows that dashboards often hide. Press F6, sort by STATE, and every D and Z process groups together. If you see a crowd of D processes all touching the same mount, the culprit is storage, and the next step is iostat -x 1 or a look at the network filesystem, not the CPU.

Making the setup stick

htop saves F2 changes to ~/.config/htop/htoprc when you quit. Useful defaults to set once:

  • Display options: "Detailed CPU time", "Show program path" off for readable commands, "Highlight program basename".

  • Meters: add "CPU average" and "Pressure Stall Information" (PSI meters exist on kernels with PSI enabled). PSI shows the share of time tasks were stalled on CPU, memory or I/O, which is a better "is this hurting" signal than raw utilisation.

  • Columns: add IO_RATE and OOM on database and application hosts.

Copy that file into your dotfiles or configuration management so every on-call engineer sees the same layout at 2 a.m.

Common mistakes

Mistake

Why it hurts

Do this instead

Treating full memory bar as an emergency

Page cache is reclaimable

Check the used figure and swap trend

Comparing load to a fixed number

Meaning depends on CPU count

Divide by CPUs; look at the trend

Killing the biggest VIRT process

Address space is not RAM use

Sort by RES or MEM%

Ignoring the S column

D crowds point at storage

Sort by state during incidents

Killing child workers

Supervisor respawns them

Use tree view; act on the parent

Key takeaways

  • Each CPU bar is split by type of work; red is kernel, cyan is steal on VMs, and detailed mode exposes IO-wait and IRQs.

  • A memory bar full of cache is normal; growing swap with D state processes is not.

  • Load average counts runnable and uninterruptible tasks, so divide by CPU count and check states before blaming CPU.

  • P, M, F4, F5 and F6 answer most questions; Z pauses the screen so you can read it.

  • Save a shared htoprc so the whole team reads the same screen.

References