Clearing Swap Space in Linux

Command for RAM usage status on the server;

free -m

Let’s assume we performed the check and the swap is bloated.

To check what size the swap has been allocated;

swapon -s

We looked at the values; the swap is heavily used, or if you want to clean the swap, run the following 2 commands in order;

swapoff -a
swapon -a

The first command turns off the swap area, and the second one turns it back on. It gets cleaned.