How to Check Swap Usage with htop in Linux

This article provides a quick overview of how to monitor swap space utilization on a Linux system using the htop command-line utility. You will learn how to read the default memory bar graphs, customize the display to show textual swap statistics, and interpret the data to ensure your system is running efficiently.

Reading the Default htop Display

When you launch htop by typing the command into your terminal, the system resource summary is displayed at the very top of the interface.

Customizing htop for Detailed Swap Metrics

If you prefer a precise numeric breakdown instead of a graphical bar, or if you want to add more detailed swap metrics to your header, you can easily customize the layout.

  1. Press F2 (or S) to enter the htop Setup menu.
  2. Use the arrow keys to navigate to the Meters column.
  3. Move to the Header layout column to choose where you want to place your metrics.
  4. In the Available meters column, locate the swap-related options.
  5. Press F4 to change the display type of the Swap meter from a “Bar” to “Text”, “LED”, or “Graph”.
  6. Press F10 to save your changes and return to the main dashboard.

Identifying Which Processes Are Using Swap

To determine exactly which applications are consuming your swap space, you can add a dedicated Swap column to the process list view.

  1. Press F2 to re-enter the Setup menu.
  2. Select Columns from the leftmost menu.
  3. Move to the Available Columns list and scroll down to find NSWAP (Number of swap pages) or SWAP (Size of swap routine).
  4. Press F5 to add it to your Active Columns.
  5. Use the F7 and F8 keys to move the column up or down to change its horizontal position on your screen.
  6. Press F10 to save. You can now click on the SWAP column header to sort all running processes by their swap memory usage.