LinuxCommandLibrary

htop

Monitor system processes interactively

TLDR

Start htop

$ htop
copy

Start htop displaying processes owned by a specific user
$ htop [[-u|--user]] [username]
copy

Display processes hierarchically in a tree view to show the parent-child relationships
$ htop [[-t|--tree]]
copy

Sort processes by a specified sort_item (use htop --sort help for available options)
$ htop [[-s|--sort]] [sort_item]
copy

Start htop with the specified delay between updates, in tenths of a second (i.e. 50 = 5 seconds)
$ htop [[-d|--delay]] [50]
copy

See interactive commands while running htop
$ <?>
copy

Switch to a different tab
$ <Tab>
copy

Display help
$ htop [[-h|--help]]
copy

SYNOPSIS


htop [OPTIONS]

PARAMETERS

-d, --delay=DELAY
    Sets the delay between updates, in tenths of a second (e.g., -d 10 for 1 second).

-s, --sort-key=COLUMN
    Sorts the process list by the specified column (e.g., -s CPU or -s PERCENT_CPU). Use man htop for a full list of valid column names.

-u, --user=USERNAME
    Shows only the processes of a specific user. Can be a username or user ID.

-p, --pid=PID,PID,...
    Shows only the specified PIDs (Process IDs). Multiple PIDs can be comma-separated.

-C, --no-color
    Starts htop in monochrome (no color) mode.

-F, --filter=FILTER
    Applies an initial filter to the process list. The filter text will be applied immediately upon startup.

-h, --help
    Displays a help message and exits.

-v, --version
    Displays version information and exits.

DESCRIPTION

htop is an interactive, real-time process viewer and system monitor for Unix-like operating systems. It is designed as an enhanced alternative to the traditional top command, offering a more user-friendly interface and advanced functionalities. Unlike top, htop allows for vertical and horizontal scrolling through the process list, enabling users to view full command lines and all processes without truncation.

It provides a visual representation of CPU, memory, and swap usage through configurable meters. Users can easily kill processes, renice them, filter the process list, and sort by various criteria directly from the interactive interface using mouse or keyboard shortcuts. Its color-coded output enhances readability, making it easier to identify different process states and resource consumption. htop excels in providing a quick, intuitive overview of system performance and running processes, making it a favorite tool for system administrators and power users.

CAVEATS

htop relies on the ncurses library for its interactive terminal interface. It might not be available or installed by default on highly minimal Linux installations. While offering significantly more features than top, its resource consumption can be marginally higher, though this difference is negligible on most modern systems.

<B>INTERACTIVE KEYBINDINGS</B>

Common htop interactive keys (also accessible via function keys):
F1/h: Help
F2/S: Setup (configure display options)
F3//: Search/Filter processes by command name
F4/\: Filter processes by user or command
F5/t: Tree view (show processes in a hierarchical tree)
F6/< or >: Select column to sort by
F7/[: Nice - (decrease process priority)
F8/]: Nice + (increase process priority)
F9/k: Kill selected process
F10/q: Quit htop
Space: Tag process (select multiple for batch operations)
l: Show open files for selected process (requires lsof)
s: Show system calls for selected process (requires strace)
M: Sort by Memory usage
P: Sort by CPU usage
T: Sort by running Time
K: Hide kernel threads
H: Hide user threads
I: Invert sort order
u: Filter by user

<B>CUSTOMIZATION</B>

The htop setup screen (accessible via F2 or S) allows extensive customization of the display. Users can select which meters appear at the top (e.g., CPU, Memory, Swap, Load Average), their order, and their display style (e.g., text, bar, LED). They can also choose which columns are displayed in the process list (e.g., PID, User, CPU%, MEM%, Command), their order, and width. Additionally, htop offers several built-in color schemes to suit different preferences or terminal backgrounds. This high degree of customizability allows users to tailor htop to their specific monitoring needs and preferences, making it an incredibly versatile tool.

HISTORY

htop was created by Hisham Muhammad and first publicly released around 2004. It was developed as a more user-friendly and feature-rich alternative to the traditional top utility, addressing several limitations and frustrations users often encountered with top, such as the inability to scroll horizontally, easily kill processes, or sort by arbitrary columns without complex commands. Its development focused on providing an interactive, colorful, and intuitive interface for process management and system monitoring, quickly gaining popularity among Linux users and becoming a staple tool in many distributions.

SEE ALSO

top(1), ps(1), pstree(1), proc(5)

Copied to clipboard