Yes. With the procps-ng version of top commonly used on Linux, run top -o SWAP to sort processes by swap usage, usually with the largest values at the top. You can also choose SWAP as the sort field inside the interactive display, which is useful if you are already monitoring the system.
Sort by swap from the command line
Start with this command:
top -o SWAP
The -o option tells procps-ng top which field to use for sorting. SWAP is the field name for the amount of a task’s memory shown as swapped out. Sorting is normally descending, so processes with the largest reported swap amounts appear first. The display continues to refresh, and the order can change as processes use or release memory.
If you are already inside top, you can usually change the sort field without quitting. This is convenient when you want to compare swap use with CPU, resident memory, or another column during the same session. If the command-line option is rejected, check which implementation of top your system provides: procps-ng is common on Linux, but BusyBox and other implementations can have different options.
Choose SWAP in the interactive display
In procps-ng top, the field-management screen lets you select which field controls sorting. The key names below assume the standard interactive mode; terminal emulators and customized configurations may affect how keys are entered.
- Run
top. - Press
fto open field management. - Use the arrow keys to highlight the SWAP field.
- Press
sto make that field the sort field, then pressqto return to the process display.
The field-management screen marks the current sort field, so check that SWAP is selected before leaving. If SWAP is not currently shown as a column, enable it in the field list as well; sorting by a field and displaying that field are related but separate choices. Depending on the version and configuration, the interface may offer additional ways to move the sort field among visible columns.
What the SWAP column measures
SWAP is a per-task estimate of memory that has been moved out of physical RAM into swap. It is not the same as VIRT, which describes a process’s virtual address space, or RES, which represents memory currently resident in physical RAM. A process can have a large virtual address space but little resident memory and little swap, or it can have a modest resident footprint alongside some swapped-out pages.
Values are commonly displayed in KiB or in a larger unit chosen by the current top settings. Read the column heading and unit indicators rather than assuming that every display is in megabytes. A value of zero means that top reports no swap for that task at that moment; it does not mean that the machine has no swap configured or that the process has never used swap.
Per-process swap figures are useful clues, not a perfect accounting of physical storage. Memory can be shared among processes, and kernel interfaces and tools may attribute shared or special memory differently. A process’s displayed SWAP should therefore not be treated as an exact measure of how much additional swap space the system would recover by terminating it.
Reading a sorted list correctly
Sorting helps identify which tasks have the largest reported amounts, but it does not by itself diagnose a problem. Consider a machine where a process appears near the top with 800 MiB of SWAP while another uses little or none. That tells you where to investigate first; it does not establish that the first process is currently causing a slowdown. Its swapped pages may be inactive, and the system may still have ample available memory.
Look at the process name, user, memory columns, and system-wide figures together. If the same process has substantial SWAP and the machine is repeatedly moving pages between RAM and swap, it may contribute to sluggishness. If the process has swap allocated but is not actively accessing those pages, its presence alone may have little effect on current responsiveness. A single snapshot cannot show whether memory pressure is getting worse, so observe the display over time.
- Use
SWAPto locate tasks with the largest reported swapped-out amounts. - Compare it with
RESto see how much memory is resident now. - Check CPU activity and system responsiveness before concluding that swap is the cause of a performance issue.
- Record whether the figures rise, fall, or stay stable across several refreshes.
Compare process swap with system-wide swap
The process list answers a different question from the summary line at the top of top. The summary reports overall memory and swap totals, while SWAP sorts individual tasks. A machine can have considerable swap in use without one obvious process dominating, and the largest individual process does not necessarily account for all system-wide swap consumption.
For a quick system-wide check, use free -h. Its Swap row reports total, used, and available swap in human-readable units. To inspect configured swap devices and files, run swapon --show. These commands complement top: use the summary tools to understand the machine’s overall state, then use the sorted process view to find possible contributors.
Linux may keep infrequently used pages in swap even when the system is not in immediate trouble. Swap being nonzero is not, by itself, proof of a memory leak or a misconfiguration. More concerning signs include persistently low available memory, substantial ongoing paging activity, and delays that coincide with that activity. Interpret several indicators together instead of treating one number as a universal threshold.
Show the column and adjust the view
If the list is sorted but you cannot see a SWAP column, use the field-management controls to add it to the displayed fields. The exact layout varies by top version and saved configuration. You can also use top -o SWAP to request the sort field at startup, then adjust the visible columns in the interface if needed.
Be aware that top can save customized field and display settings. A future session may therefore open with a different layout or sort choice than expected. If your view seems inconsistent, check the sort-field marker in field management and consider whether a saved configuration is active. For repeatable checks on several machines, note the top implementation and version as well as the command you used.
Common limitations and troubleshooting
If top -o SWAP reports an unknown field, first confirm the command syntax and identify the installed program with a version or help option. Some lightweight systems ship BusyBox top, whose supported fields and key bindings differ from procps-ng. On a minimal container, even the usual process information may be restricted by its namespace, permissions, or available /proc data.
If values appear as zero, do not assume the column is broken. The tasks may simply have no reported swap, the selected process view may exclude tasks you expected to see, or the tool may be using a different accounting interface. Permissions and kernel details can affect what a user can inspect. Try a privileged view only when you have a legitimate administrative reason, and remember that elevated access does not make every memory figure exact.
Finally, avoid confusing the SWAP column with a ranking of current disk activity. It describes an amount associated with swapped memory, not a rate of pages being read from or written to swap right now. To investigate active paging, use appropriate system monitoring tools and compare their activity over time. A large stored amount and heavy ongoing swap traffic are related possibilities, but they are not interchangeable measurements.
Alternatives for a closer look
If you need a report rather than an interactive display, smem is a commonly used alternative that can report swap alongside proportional and unique memory estimates. It is a separate tool and may not be installed by default. Check its local manual for supported sort-field names and options, since packaging and versions can vary.
For one process, Linux exposes a VmSwap entry in /proc/PID/status on kernels that provide it. Replace PID with the process ID, for example by inspecting /proc/1234/status. This is helpful for checking a specific task without relying on the current top layout. Standard ps output commonly includes virtual and resident memory columns, but those are not substitutes for a per-process swap field unless the particular implementation explicitly provides one.
Use these alternatives for different purposes: top is convenient for live sorting, free and swapon summarize system-wide swap, and /proc or a reporting tool can help with focused investigation. None turns process-level memory attribution into a perfect measurement of reclaimable system resources.
Related
Frequently Asked Questions
What is the command to sort top by swap?
For procps-ng on Linux, run top -o SWAP. It requests SWAP as the sort field and normally puts the largest values first.
How do I sort by swap without restarting top?
In standard procps-ng top, press f, highlight SWAP with the arrow keys, press s, and then press q to return to the process list.
Why is the SWAP column missing?
The column may not be enabled in the current field layout. Open field management and add SWAP to the displayed fields. The available controls can differ in BusyBox or other versions of top.
Does a high SWAP value mean a process is using swap right now?
It means the displayed amount is reported as swapped out, not that pages are actively moving at this instant. Use system paging activity and performance indicators to assess current pressure.
Is SWAP the same as VIRT or RES?
No. VIRT is virtual address space, RES is memory resident in RAM, and SWAP is memory reported as swapped out. They describe different aspects of a process’s memory.