# htop — Interactive Process Monitor for the Terminal

> Practical guide to htop — monitor, sort, filter and kill processes live in the terminal with the comfortable, colourful top replacement.

Source: https://www.jpkc.com/db/en/cheatsheets/shell-system/htop/

<!-- PROSE:intro -->
htop is an interactive process viewer for the terminal and a comfortable replacement for `top`: colour-coded CPU and memory meters, mouse support, a tree view and the ability to kill processes with a single keystroke – without typing PIDs. This guide walks you through the command-line options for launching htop and the keys that matter most while it runs, from searching and filtering to sorting and adjusting nice values.
<!-- PROSE:intro:end -->

## Basic Usage

`htop` — Start htop in interactive mode.

```bash
htop
```

`htop -u USER` — Show only processes belonging to a specific user.

```bash
htop -u www-data
```

`htop -p PID1,PID2` — Monitor specific processes by PID.

```bash
htop -p 1234,5678
```

`htop -d TENTHS` — Set the update delay in tenths of seconds (default: 15 = 1.5s).

```bash
htop -d 10
```

`htop -t` — Start in tree view mode.

```bash
htop -t
```

`htop -s COLUMN` — Sort by a specific column.

```bash
htop -s PERCENT_MEM
```

`htop -H` — Highlight new and old (changed) processes on startup.

```bash
htop -H
```

`htop -C` — Start in monochrome (no color) mode.

```bash
htop -C
```

## Function Keys (Bottom Bar)

`F1 / h` — Help screen.

`F2 / S` — Setup — configure meters, columns, colors, and display options.

`F3 / /` — Incremental search by process name.

`F4 / \` — Filter processes by name (only matching processes shown).

`F5 / t` — Toggle tree/forest view.

`F6 / >` — Sort by a selected column.

`F7` — Decrease nice value (increase priority) of selected process.

`F8` — Increase nice value (decrease priority) of selected process.

`F9 / k` — Kill selected process (choose signal from menu).

`F10 / q` — Quit htop.

## Navigation

`↑ / ↓` — Move cursor up/down through process list.

`← / →` — Scroll horizontally to see full command lines.

`PgUp / PgDn` — Scroll one page up/down.

`Home / End` — Jump to top/bottom of process list.

`Space` — Tag/untag a process (for batch operations).

`U` — Untag all processes.

`c` — Tag process and its children.

## Sorting

`P` — Sort by CPU usage.

`M` — Sort by memory usage.

`T` — Sort by time.

`I` — Invert sort order.

`F6 / >` — Open sort column selector.

## Display Toggles

`H` — Toggle user threads display.

`K` — Toggle kernel threads display.

`t / F5` — Toggle tree view.

`p` — Toggle program path in command column.

`m` — Toggle merged command display (useful for multi-threaded apps).

`e` — Show environment variables for selected process.

`w` — Wrap long command lines.

`u` — Show only processes of a selected user.

## Process Actions

`k / F9` — Kill selected process. Shows signal selection menu.

`F7 / ]` — Decrease nice value (higher priority). Requires root.

`F8 / [` — Increase nice value (lower priority).

`l` — Show open files for selected process (lsof).

`s` — Show system calls for selected process (strace).

`a` — Set CPU affinity for selected process.

`i` — Set I/O priority for selected process (ionice).

## Header Meters

`CPU bars` — Color-coded: blue=low-priority, green=normal, red=kernel, cyan=virtualized, gray=I/O wait.

`Memory bar` — Color-coded: green=used, blue=buffers, orange/yellow=cache, cyan=ZFS cache.

`Swap bar` — Red=swap used. Any swap usage may indicate memory pressure.

`Load average` — 1/5/15 minute averages. Compare against CPU count.

`Uptime` — System uptime since last boot.

`Tasks` — Total processes, threads, running, and kernel threads.

<!-- PROSE:outro -->
## Conclusion

htop makes system monitoring fast and tangible: one invocation shows load, memory and processes in real time, and search (`/`), filter (`F4`), tree view (`F5`) and sorting (`F6`) are all a keystroke away. Be careful with `F9`/`k`, though: a kill terminates the selected process immediately, and any unsaved work in a running process is lost – check the target and the signal before you confirm. Your settings (meters, columns, colours) live in `~/.config/htop/htoprc`. If htop feels too plain, `btop` (a modern, more graphical monitor) and the classic `top` are both worth a look.

## Further Reading

- [htop – official project site](https://htop.dev/) – source, downloads and FAQ for the process monitor
- [htop man page](https://man7.org/linux/man-pages/man1/htop.1.html) – complete reference for options and interactive keys
<!-- PROSE:outro:end -->

## Related Commands

- [top](https://www.jpkc.com/db/en/cheatsheets/shell-system/top/) – the classic process monitor, pre-installed on almost every system
- [ps](https://www.jpkc.com/db/en/cheatsheets/shell-system/ps/) – one-off snapshot of running processes for scripts and pipes
- [free](https://www.jpkc.com/db/en/cheatsheets/shell-system/free/) – show free and used physical and swap memory

