Skip to content

htop Command Cheat Sheet

htop is an advanced, interactive text-mode process viewer. It is a modern alternative to top, featuring full vertical and horizontal scrolling, mouse usage, and visual meters.


Synopsis

htop [options]

Interface Overview

  1. Header (Top): CPU usage (per core), Memory/Swap usage, Load Average, Uptime.
  2. Body (Middle): List of processes.
  3. Footer (Bottom): Menu shortcuts (F-keys).

Keyboard Shortcuts

Key Function Description
F1 / ? Help Show cheat sheet of keys
F2 / S Setup Change colors, columns, meters
F3 / / Search Find process by name (incremental)
F4 / \ Filter Show only matching processes
F5 / t Tree Toggle tree view (parent/child relationship)
F6 / > Sort Select column to sort by (CPU%, MEM%, etc.)
F7 / [ Nice - Increase priority (requires root)
F8 / ] Nice + Decrease priority
F9 / k Kill Send signal to selected process
F10 / q Quit Exit htop

Interactive Features

Killing Processes (F9)

Unlike kill command where you need a PID, in htop: 1. Select the process using Arrow keys. 2. Press F9. 3. Select signal from the list on the left (default is 15 SIGTERM). 4. Press Enter to send.

Filtering (F4)

Crucial for finding specific services. 1. Press F4. 2. Type nginx. 3. Only nginx processes are shown. 4. Press F4 and Esc to clear.

Tree View (F5)

Visualize process hierarchy. Shows which process spawned which. Useful for identifying the parent of a stuck worker process.


Command Line Options

Start with Filter

htop -F nginx

Show Specific User Processes

htop -u alice

Sort by Column on Launch

htop -s PERCENT_MEM

Delay Interval

Update every 0.5 seconds (default is usually 1.5 or 2).

htop -d 5

Column Explanations

  • PID: Process ID
  • USER: Owner
  • PRI: Priority (kernel view)
  • NI: Nice value (user view)
  • VIRT: Virtual Memory (total requested)
  • RES: Resident Memory (physical RAM used)
  • SHR: Shared Memory
  • S: State (R=Running, S=Sleeping, D=Disk Sleep/Uninterruptible, Z=Zombie)
  • CPU%: CPU usage
  • MEM%: Memory usage
  • TIME+: Total CPU time consumed
  • Command: The actual command

Notes

  • Mouse Support: You can click column headers to sort, or click processes to select them.
  • Config: Saved in ~/.config/htop/htoprc.
  • htop shows threads by default as separate lines (in green text usually). You can disable this in Setup (F2) -> Display options -> "Hide userland process threads".