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.

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.

  1. Navigate to the Parent Process: Use the Up and Down arrow keys to highlight the main parent process you want to manage.
  2. Collapse the Branch: Press the Minus key (-). 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.
  3. Expand the Branch: Press the Plus key (+) or the Equal key (=) 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.