In a Linux operating system, memory swapping helps manage RAM (Random Access Memory) when it gets full.
What is Swap Space?
RAM stores active applications and processes. If RAM is full, Linux moves less-used data to swap space, which is located on the disk. This process is called swapping.
Since disks are slower than RAM, accessing swap space takes more time. Too much swapping can slow down the system.
Checking RAM and Swap Usage
You can check RAM and swap usage with this command:
free -m
This shows memory usage in megabytes (MB).
Swappiness – How Often Linux Uses Swap
Linux controls how often it moves data from RAM to swap using a setting called swappiness. You can check its value with this command:
cat /proc/sys/vm/swappiness
A high swappiness value (like 60) means Linux moves data to swap more often. A lower value (like 10) keeps data in RAM as long as possible.