How to Collapse or Expand Process Trees in htop?
The htop interactive process viewer allows users to
monitor system resources and manage running processes in a dynamic,
user-friendly terminal interface. When viewing processes in a
hierarchical tree format, navigating large numbers of child processes
can become overwhelming. This article provides a quick guide on how to
toggle the tree view mode and use specific keyboard shortcuts to
collapse and expand individual process branches, enabling more efficient
system monitoring.
Enabling Tree View in htop
Before you can collapse or expand specific process branches, you must
ensure that htop is actively displaying processes in its
hierarchical tree format.
- The Shortcut: Press
F5(orton some configurations) to toggle between the standard sorted list view and the tree view. - The Visual Cue: Once enabled, you will see visual
nestings (using lines like
└─) showing which child processes belong to which parent applications, such as individual tabs under a web browser or worker threads under a web server.
Collapsing and Expanding Specific Branches
Once you are in tree view, you can easily clean up your terminal screen by hiding or revealing the child processes of a specific parent.
- Navigate to the Parent Process: Use the Up and Down arrow keys to highlight the main parent process you want to manage.
- Collapse the Branch: Press the
Minuskey (-). This will hide all child processes underneath the selected parent, instantly freeing up vertical space on your screen. A small plus sign or indicator will usually appear next to the process to show it contains hidden elements. - Expand the Branch: Press the
Pluskey (+) or theEqualkey (=) on standard keyboards. This will reveal all the previously hidden child processes running under that specific parent.
Quick Keyboard Shortcut Reference
| Action | Keyboard Shortcut |
|---|---|
| Toggle Tree View On/Off | F5 or t |
| Collapse Selected Branch | - (Minus) |
| Expand Selected Branch | + (Plus) / = (Equal) |
By mastering these three basic keystrokes, you can quickly declutter
your htop interface, isolate resource-heavy application
chains, and maintain a cleaner overview of your Linux system’s
performance.