# free — Show RAM and Swap Memory Usage

> Practical guide to free: display RAM and swap usage and learn why on Linux the available column matters more than free.

Source: https://www.jpkc.com/db/en/cheatsheets/shell-system/free/

<!-- PROSE:intro -->
`free` gives you a snapshot of your Linux system's memory usage in seconds: how much physical RAM and swap are in use and – most importantly – how much memory is actually available for new programs. The classic beginner mistake is panicking at a low `free` column. This guide walks you through the key options and explains why, on Linux, the column that matters is `available`, not `free`.
<!-- PROSE:intro:end -->

## Basic Usage

`free` — Show memory usage in kibibytes (default).

```bash
free
```

`free -h` — Show memory usage in human-readable format (auto-select KB/MB/GB).

```bash
free -h
```

`free -m` — Show memory usage in mebibytes (MiB).

```bash
free -m
```

`free -g` — Show memory usage in gibibytes (GiB).

```bash
free -g
```

`free -b` — Show memory usage in bytes.

```bash
free -b
```

`free --si` — Use SI units (powers of 1000 instead of 1024).

```bash
free -h --si
```

## Display Options

`free -t` — Show a total line (RAM + swap combined).

```bash
free -ht
```

`free -w` — Wide output: show buffers and cache as separate columns.

```bash
free -wh
```

`free -l` — Show low and high memory statistics (32-bit systems).

```bash
free -lh
```

`free -v` — Show version information.

```bash
free -v
```

## Continuous Monitoring

`free -s <seconds>` — Repeat the output every n seconds continuously.

```bash
free -h -s 5
```

`free -c <count> -s <seconds>` — Repeat the output n times with a delay between each.

```bash
free -h -c 10 -s 2
```

`watch free -h` — Use watch for a refreshing display (alternative to -s).

```bash
watch -n 2 free -h
```

## Output Columns Explained

`total` — Total installed memory (or total swap space).

```bash
free -h | awk '/Mem:/ {print $2}'
```

`used` — Memory actively in use by processes (total - free - buffers - cache).

```bash
free -h | awk '/Mem:/ {print $3}'
```

`free` — Memory not being used at all (completely unused).

```bash
free -h | awk '/Mem:/ {print $4}'
```

`shared` — Memory used by tmpfs and shared memory segments.

```bash
free -h | awk '/Mem:/ {print $5}'
```

`buff/cache` — Memory used for disk buffers and page cache (reclaimable by the kernel).

```bash
free -h | awk '/Mem:/ {print $6}'
```

`available` — Estimated memory available for new applications (without swapping). This is the most useful metric.

```bash
free -h | awk '/Mem:/ {print $7}'
```

## Common Patterns

`free -h | awk '/Mem:/ {print $7}'` — Show only the available memory.

```bash
free -h | awk '/Mem:/ {print "Available: " $7}'
```

`free -h | awk '/Mem:/ {printf "Used: %s / %s (%.1f%%)\n", $3, $2, $3/$2*100}'` — Show memory usage as a percentage.

```bash
free -m | awk '/Mem:/ {printf "RAM: %.1f%% used\n", $3/$2*100}'
```

`free -h | awk '/Swap:/ {print $3}'` — Check how much swap is being used.

```bash
free -h | awk '/Swap:/ {print "Swap used: " $3}'
```

`free -m | awk '/Mem:/ {if ($7 < 500) print "WARNING: Low memory!"}'` — Alert if available memory drops below a threshold (MB).

```bash
free -m | awk '/Mem:/ {if ($7 < 500) print "WARNING: Only " $7 "MB available!"}'
```

`cat /proc/meminfo` — Show detailed memory information from the kernel (more granular than free).

```bash
cat /proc/meminfo | head -20
```

`cat /proc/meminfo | grep -i huge` — Check huge pages configuration and usage.

```bash
cat /proc/meminfo | grep -i huge
```

`vmstat -s` — Show detailed memory statistics in a different format.

```bash
vmstat -s | head -10
```

<!-- PROSE:outro -->
## Conclusion

`free` is a pure read-only command with no risk – you can run it any time without worrying. The key takeaway: don't panic at a low `free` column. Linux deliberately uses spare RAM as a page cache to speed up disk access, and it reclaims that memory instantly the moment applications need it. The honest answer to "how much memory do I have left?" lives in the `available` column, not in `free`. For a continuous live view, reach for `free -s` or `watch`; for deeper analysis, turn to `vmstat`, `top` or `htop`. Note that macOS has no `free` – there, `vm_stat` provides comparable information.

## Further Reading

- [free(1) man page](https://man7.org/linux/man-pages/man1/free.1.html) – the official procps-ng manual page for free
- [Linux ate my RAM](https://www.linuxatemyram.com/) – the classic explanation of why a low “free” value is normal on Linux
<!-- PROSE:outro:end -->

## Related Commands

- [top](https://www.jpkc.com/db/en/cheatsheets/shell-system/top/) – interactive real-time process and memory monitor
- [htop](https://www.jpkc.com/db/en/cheatsheets/shell-system/htop/) – friendlier, colourful alternative to top with mouse support
- [vmstat](https://www.jpkc.com/db/en/cheatsheets/shell-system/vmstat/) – overview of memory, swap, I/O and CPU statistics

