linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
  • Introduction
  • Lessons
  • How it works
  • Simulator
  • Knowledge base
  • Interview prep
Index
Categories
All entries
Footer
linuxlab-TutorialsPricingAboutPrivacy & cookies
Copyright © 2026 LinuxLab. All rights reserved.
home/linux/kb/Commands/cmd-htop

kb/commands ── Commands ── beginner

htop: interactive process monitor

htop is an interactive TUI process monitor. F-keys: F3 search, F4 filter, F5 tree, F6 sort, F9 kill. Color meters at the top, process list below. It replaces top wherever it is available.

view as markdownaka: htop, htop-command, btop

Why htop instead of top

top is always present, but it is read-only by default, sorts in a single fixed order, and shows no process tree. htop is color-coded, interactive, and supports mouse clicks. On modern distros it is typically the first package installed after setting up a system.

Alternatives: btop (better visuals, graphs), glances (includes network and disk), atop (disk load history). htop is the de facto standard.

Starting htop

bash
htop                       # all processes
htop -u user               # only a specific user's processes
htop -p $(pgrep nginx)     # only nginx PIDs
htop -t                    # open directly in tree mode
htop --filter=nginx        # filter by name

What the top meters show

Default layout:

CPU   [|||||||||                    25%]
Mem   [||||||||||||                3.2G/16G]
Swp   [                            0K/2G]
  • Each CPU core has its own bar (can be merged into an average).
  • CPU colors: green = user, red = kernel, blue = low-priority, orange = iowait.
  • Mem colors: green = used, blue = buffers, yellow = cache (cache is not lost memory).
  • Tasks: total | running | threads.
  • Load average and uptime.

In F2 Setup → Meters you can add: Hostname, temperature (Temperature), battery, network (netio), disk, ZFS ARC.

F-keys (or Esc combinations)

KeyAction
F1 / hhelp
F2Setup: settings menu
F3 / /Search by name (incremental)
F4 / \Filter (persistent)
F5 / tTree mode
F6Sort by: choose column
F7/F8Renice (priority)
F9 / kSend signal (SIGTERM by default)
F10 / qQuit
Htoggle threads
Ktoggle kernel threads
ufilter by user (select from list)
Spacemark/unmark a process (for bulk actions)
ctag process and its children
sstrace the selected process (requires strace to be installed)
llsof: open files of the selected process
M/P/Tsort by Memory/CPU/Time
+/-expand/collapse subtree in tree mode

Search (F3) finds the first match; press F3 again for the next one. Filter (F4) hides everything except matches. Esc clears the filter.

Tree mode (F5)

Shows the parent to child hierarchy. Useful for understanding what launched what:

systemd
 ├─ sshd
 │   └─ sshd: user
 │       └─ bash
 │           └─ htop
 ├─ nginx
 │   ├─ nginx: worker
 │   └─ nginx: worker
 └─ postgres
     ├─ postgres: writer
     └─ postgres: checkpointer

This helps you find which parent is spawning zombie children.

Useful columns

Add via F2 → Columns:

  • CGROUP: the cgroup the process belongs to (shows systemd units and containers).
  • OOM: oom_score. The higher the score, the more likely the process is to be hit by [[oom-killer|OOM-killer]].
  • IO_RATE: read/write rate (requires root and --enable-delayacct).
  • STARTTIME: when the process was started.
  • PROCESSOR: which CPU is executing the process.
  • NLWP: thread count.

Color cues

  • Yellow process name: kernel thread.
  • Red PID: process is in state D (uninterruptible sleep, usually waiting on I/O).
  • Space-marked entries: selected; F9 will send a signal to all of them.

How to kill a process through htop

  1. Find the process (F3 or mouse).
  2. Press F9 to open the signal menu.
  3. Choose: SIGTERM (15) for a clean exit, SIGKILL (9) to force-terminate.

Between TERM and KILL: SIGINT (2) is equivalent to Ctrl+C; SIGHUP (1) usually triggers a reload without a restart. See signals for details.

htop inside a container

By default a container sees all host processes (if it does not have its own PID namespace). Inside a Docker container htop shows only its own processes. That is normal because of the [[namespaces|PID namespace]].

To see host processes from inside a container:

bash
docker run --pid=host -it alpine sh -c 'apk add htop && htop'

When something looks wrong

  • load 8 but CPU is idle. I/O wait. Processes are in state D, sleeping on disk. Check iostat -x 1 or the iowait color in htop.
  • Memory looks nearly full but 200 MB shows free. Look at Available, not Free. Cache and buffers are returned to the kernel when needed.
  • Process does not die even with SIGKILL. State D (uninterruptible). It is waiting on NFS, disk, or a kernel lock. Only a reboot or unblocking the device helps.
  • htop itself appears at the top of the list. Go to F2 → Display and enable "Hide userland process threads" and "Hide kernel threads" to reduce htop's own CPU usage.
  • Container names do not appear. Add the CGROUP column. The container name is in the path /sys/fs/cgroup/.../docker-XXXXX.

Alternatives

  • top: always present, base utility.
  • btop: graphs, ASCII art; slower on older CPUs.
  • glances: network, disk, and processes in one window; written in Python.
  • atop: background daemon with history; lets you examine a past load spike.

§ команды

bash
htop

Run with no arguments to see all processes for the current user and the system.

bash
htop -u www-data

Show only a specific user's processes. Handy on a shared server.

bash
htop -p $(pgrep -d, nginx)

Show only nginx PIDs. Quick way to focus on a single service.

bash
htop -d 50

Refresh every 5 seconds (50 x 0.1 s). Reduces CPU overhead of the monitor itself.

bash
htop --tree

Open directly in tree mode to see parent-child relationships at a glance.

bash
htop --sort-key=PERCENT_MEM

Start sorted by memory usage. Useful for tracking down memory leaks.

bash
killall -USR1 htop

Not an htop argument. Sends a signal to the htop process from another terminal.

§ см. также

  • cmd-psps: process snapshotps prints a snapshot of processes at the moment it runs. Two dialects: BSD (`aux`, no dash) and UNIX (`-ef`, with dash). `-o` specifies columns. For continuous monitoring, use [[cmd-htop|htop]].
  • signalsSignals (SIGTERM, SIGKILL, SIGHUP)A signal is an asynchronous notification to a process from the kernel or another process. TERM asks it to quit, KILL kills it now, HUP reloads config.
  • oom-killerOOM killerOOM killer is the kernel mechanism that picks and terminates a process when the system hits its memory limit. In containers it works per-cgroup.
  • load-averageLoad averageLoad average is three numbers in `uptime`: exponential averages of the run-queue length (R + D state) over 1, 5, and 15 minutes. It only makes sense in the context of `nproc`.
  • cmd-stracestrace: what syscalls a process makes`strace` shows in real time which system calls a process makes and with what arguments. The primary tool when a process goes silent.
Footer
linuxlab-
Copyright © 2026 LinuxLab. All rights reserved.
Tutorials
Pricing
About
Privacy & cookies