free Command Guide for Checking Memory Usage
free shows how much memory your system is using and how much is left — and the single most important thing to learn is that “free” memory being low is normal, because Linux uses spare RAM for disk caching.
What is free, and Why Use It?
free prints a small table of memory statistics: total, used, and available RAM, plus swap. It is the standard first check whenever a system feels slow, an application is being killed, or you suspect a memory leak.
The confusion every beginner hits: the “free” column is often tiny, and people panic. Do not. Linux deliberately spends unused RAM caching disk data, and that memory is released instantly when applications need it. The number that actually answers “can I start another big program?” is the available column.
Why Learn free?
- Memory exhaustion kills processes — when RAM and swap are both gone, the kernel starts killing programs (the “OOM killer”);
freeis how you see that coming. - The available column is the real answer — learning to read it instead of the free column prevents the most common false alarm in Linux monitoring.
- It is instant and everywhere — one command, no install, works on every distro, perfect for scripts and SSH triage.
- It pairs with the rest of this section — high load from uptime plus low available memory points at the same investigation.
“Free memory is wasted memory.” Linux fills RAM with cache on purpose. Judge your headroom by the available column, never by free.
1. Run It and Read the Output
free -h
total used free shared buff/cache available
Mem: 15.6Gi 4.2Gi 2.1Gi 312Mi 9.3Gi 10.8Gi
Swap: 2.0Gi 0B 2.0Gi
-h— human-readable: printsGi/Miinstead of raw kilobytes. Use this by default.
Read the Mem: row:
| Column | Meaning |
|---|---|
total | Total installed RAM |
used | Memory actively held by processes and the kernel |
free | Completely untouched RAM — normal for this to be small |
shared | Memory shared between processes (tmpfs, shared libraries) |
buff/cache | Disk cache the kernel can give back at any moment |
available | Estimate of what a new program could actually get — used + buff/cache minus what must stay |
The modern rule: available ≈ what matters. On the sample above, 10.8Gi is available even though only 2.1Gi is “free”.
2. Watch Memory Over Time
A single snapshot tells you the current state; repeated snapshots tell you the story. To refresh every 2 seconds:
watch -n 2 free -h
If used climbs steadily while available shrinks, something is leaking memory. To catch the culprit, follow up with top sorted by memory (M inside top) or htop (F2 → sort by PERCENT_MEM).
3. Understand Swap
The Swap: row shows swap space — disk reserved as emergency RAM:
Swap: 2.0Gi 0B 2.0Gi
total 2.0Gi— swap configured.used 0B— nothing has been pushed out to disk yet.
Swap usage is not automatically bad. The kernel moves rarely-touched pages to swap to make room for cache; a system can have some swap used and still be perfectly fast. It becomes a problem when swap usage is growing steadily and the machine is slow — that means real memory pressure.
To see which processes hold the most swap, use smem or check per-process numbers in top (the SWAP column after enabling it, or look at VIRT vs RES).
4. See Memory in Raw Numbers
Without -h, free prints kilobytes — useful in scripts where you want numbers you can compare:
free
total used free shared buff/cache available
Mem: 16367412 4423108 2201876 319412 9742428 11323988
Swap: 2097148 0 2097148
All values are in KiB. The raw /proc/meminfo file behind it has over 40 fields:
grep -E "MemTotal|MemAvailable|SwapTotal" /proc/meminfo
MemTotal: 16367412 kB
MemAvailable: 11323988 kB
SwapTotal: 2097148 kB
5. Use free in Scripts
A minimal “am I out of memory?” check uses the available column:
# Alert if available memory drops below 500 MiB
avail_kb=$(free | awk '/^Mem:/ {print $7}')
if [ "$avail_kb" -lt 512000 ]; then
echo "WARNING: only ${avail_kb} KiB available"
fi
The $7 is the available column of the Mem: row in default (non--h) output.
Common Pitfalls
- Panic at a low
freevalue — it is supposed to be low. Readavailable; that is the real headroom. - Assuming swap usage means the system is broken — idle swap is normal tuning, not failure. Only growing swap with slow performance is a problem.
- Forgetting
-hin terminal output — raw kilobyte numbers are hard to read; use-hwhen looking, raw when scripting. - Confusing
freewith disk space — memory and disk are different resources; disk headroom is df’s job, notfree’s. - Blaming the wrong process —
freeis system-wide. To find which process ate the memory, go straight to top or htop.
Related Pages
| Page | Relationship |
|---|---|
| uptime | The other quick health check — load instead of memory |
| top | Finds the processes behind the memory numbers |
| htop | Interactive per-process memory view |
| vmstat | Shows swap activity (si/so columns) over time |
| df | Disk space — a different resource people confuse with RAM |
free Cheatsheet
| Command | What it does |
|---|---|
free -h | Memory table in human-readable units (default choice) |
free | Same table in raw kilobytes (script-friendly) |
free -h -s 2 | Keep printing every 2 seconds until Ctrl-C |
watch -n 2 free -h | Same idea via watch |
free -h | awk '/^Mem:/ {print $7}' | Extract available memory for scripts |
grep MemAvailable /proc/meminfo | The authoritative available-memory figure |
cat /proc/meminfo | Every memory statistic the kernel tracks |