How to Sort by Memory Usage in htop?

The htop command-line utility is an interactive system monitor for Linux that allows users to track system resources in real time. While it defaults to sorting tasks by CPU usage, you can quickly reconfigure it to sort processes by memory consumption instead. This article provides a straightforward, step-by-step guide on how to change the sort order using keyboard shortcuts or the interactive menu, helping you identify memory-hogging applications instantly.

Sorting Memory with Keyboard Shortcuts

The fastest way to sort your processes by memory usage in htop is by using built-in keyboard shortcuts. Once you have opened the tool by typing htop in your terminal, use one of the following methods:

Sorting Memory Using the Mouse

If your terminal emulator supports mouse interactions, htop allows you to navigate the interface with direct clicks:

  1. Locate the column headers at the top of the process list (e.g., PID, USER, CPU%, MEM%).
  2. Click directly on the MEM% header to sort processes by their percentage of RAM utilization.
  3. Click the header a second time if you need to toggle between ascending and descending order.

Alternative Column Metrics for Memory

When analyzing memory in htop, you might want to sort by different types of memory allocations depending on your troubleshooting needs. You can use the F6 menu to sort by these specific columns: