free — Display Memory Usage
free -h # Human readable (MB/GB)
free -m # In megabytes
free -s 2 # Update every 2 seconds
Output:
total used free shared buff/cache available
Mem: 7.7G 3.2G 1.5G 450M 3.0G 3.8G
Swap: 2.0G 100M 1.9G
Understanding the columns
| Column | Meaning |
|---|---|
| total | Total RAM |
| used | Used by processes |
| free | Completely unused |
| shared | Used by tmpfs |
| buff/cache | Used by OS caching |
| available | Available for new processes |
⚠️ available is what matters, not free. Linux uses free RAM for disk cache (buff/cache) which gets freed when apps need it.
Other memory commands
cat /proc/meminfo # Detailed memory info
vmstat 1 5 # Virtual memory stats (5 iterations)
Swap space
Swap is disk space used as overflow RAM. It's much slower.
swapon --show # Show swap usage