🚀 HTOP Commands: The DevOps Cheat Code

I. Startup & Navigation

htop Launch the Interactive Monitor +

What: Starts the real-time, colorful `htop` interface.

Why: This is the entry point! It starts the interactive, real-time interface, showing your CPU, memory, and a full list of all running processes.

↑ / ↓ Select Process +

What: Moves the selection up/down the process list.

Why: You need to select a process to act on it (like killing or renicing). These keys move the highlight bar.

F10 / q Exit Program +

What: Closes the htop interface.

Why: Quits the interactive monitor and returns you to your shell prompt.

II. Core Process Management

F9 / k Kill Selected Process +

What: Sends a termination signal (SIGKILL, SIGTERM, etc.) to the selected process(es).

Why: This is how you stop a runaway or stuck process. It opens a sub-menu to choose the termination signal (e.g., `SIGTERM` for a gentle kill, `SIGKILL` for a brutal, immediate stop).

F7 / F8 Change Nice Value (Priority) +

What: `F7` increases priority (lower nice value). `F8` decreases priority (higher nice value).

Why: Adjusting priority (renicing) lets you tell the kernel which processes matter more. Increase priority for a critical build, decrease it for a background chore.

III. Viewing & Filtering

F5 / t Tree View Toggle +

What: Switches between a flat list and a hierarchical tree of processes.

Why: This organizes processes hierarchically, showing parent-child relationships. Essential for seeing what process started another (e.g., seeing all child threads under a web server).

F3 / / Search Processes +

What: Incremental search for a process name or command line.

Why: For finding a specific process by name (like `nginx` or `kubelet`). You type, and `htop` jumps to the first match.

F4 / \ Filter Processes +

What: Hides all processes that do not match the entered text.

Why: Gives you a clean, focused view of only the processes that match your term (e.g., only processes run by the `dev` user).

F6 / > Sort By Column +

What: Opens a menu to select the column to sort by (CPU, MEM, PID, etc.).

Why: This is your primary diagnostic tool. You can quickly sort by `%CPU` or `%MEM` to see the top resource consumers, identifying what's spiking your load.

Space Tag/Select Process +

What: Tags the currently selected process.

Why: Allows you to select multiple processes (tag them all!) and then perform a single action (like a **Kill** via **F9**) on the entire group at once.

IV. Advanced & Customization

F2 / S Setup Menu (Customize HTOP) +

What: Opens the configuration screen for meters, columns, and color schemes.

Why: This is where you customize *everything*. Pro-tip: adding **IO Read/Write** metrics here is awesome for I/O-bound troubleshooting!

s Trace System Calls (strace) +

What: Runs the `strace` utility on the selected process.

Why: This is a deep-dive tool that shows you what kernel calls a process is making (like reading a file or opening a socket), essential for debugging complex application failures.

l List Open Files (lsof) +

What: Runs the `lsof` utility on the selected process.

Why: Super handy for debugging, as it shows you all the files, sockets, and libraries a process is currently using. Crucial for tracking down "Too many open files" errors.