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.
- The Swp Bar: Look for the row labeled Swp (usually located directly beneath the Mem row).
- Visual Meter: It features a colored bar graph showing visual consumption.
- Textual Values: Next to the bar, you will see two
numbers separated by a forward slash (for example,
140M/2.00G). - The first number represents the total amount of swap space currently used by the system.
- The second number represents the total swap space available on the machine.
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.
- Press F2 (or S) to enter the
htopSetup menu. - Use the arrow keys to navigate to the Meters column.
- Move to the Header layout column to choose where you want to place your metrics.
- In the Available meters column, locate the swap-related options.
- Press F4 to change the display type of the Swap meter from a “Bar” to “Text”, “LED”, or “Graph”.
- 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.
- Press F2 to re-enter the Setup menu.
- Select Columns from the leftmost menu.
- Move to the Available Columns list and scroll down to find NSWAP (Number of swap pages) or SWAP (Size of swap routine).
- Press F5 to add it to your Active Columns.
- Use the F7 and F8 keys to move the column up or down to change its horizontal position on your screen.
- Press F10 to save. You can now click on the SWAP column header to sort all running processes by their swap memory usage.