How to check swap space in linux using top
- ubuntu show swap usage
- ubuntu list swap space
- ubuntu check if swap is on
- ubuntu check swap size
Check swap usage by process.
How to Check Swap Space in Linux
You can check swap the same way you check memory usage in Linux: using the free command.
If you use the free command with human readable output (with option -h), it will show you the RAM and Swap uses.
For my system, it shows the following output:
As you can see in the above output, my system has 14 GB of total swap space and out of that 1.1 GB is being used.
Htop show swap usage per process
Around 13 GB of swap space is free.
There are more ways to check swap usage in Linux and you may get some additional information about swap as well.
Other ways to check swap usage in Linux
My favorite way to check swap usage in Linux is by using the swapon command.
This is a command dedicated for handling swap memory. Apart from giving accurate information about the swap space being used, it also tells you if the swap space is a partition or a swap file.
You can use it like this:
As you can see in the output, the total swap space is 14.9 GB (not 14 GB as free command showed).
1.1 GB is being used and it’s a swap partition, not a swap file.
Using swap file is a better idea because