free command in Linux: memory usage

Updated November 1, 2026

The free command shows how much RAM is used, free, and cached.

Syntax

free [-h]

Common cases

free -h            # human-readable sizes: K, M, G
free -m            # in megabytes
free -s 2          # refresh every 2 seconds
cat /proc/meminfo  # the source of these numbers

Sample output

$ free -h
               total        used        free      shared  buff/cache   available
Mem:            11Gi       2.2Gi       9.4Gi       164Mi       450Mi       9.5Gi
Swap:           12Gi          0B        12Gi
$ cat /tmp/big.bin > /dev/null       # read a 2 GB file
$ free -h
               total        used        free      shared  buff/cache   available
Mem:            11Gi       1.2Gi       8.6Gi       164Mi       2.3Gi        10Gi
Swap:           12Gi          0B        12Gi

How it works: read available, not free

A healthy system has almost no free memory, and that is fine: the kernel gives unused memory to the disk cache to speed up reads, and hands it back to a program on demand. So you read the available column, not free - that is how much memory programs can really use without swapping. The warning sign is not a low free but rising swap together with a low available.

Common mistakes

The free columns do not add up, and that is on purpose. In procps-ng 4.0.4 the used column is computed as total minus available, not as total minus free minus buff/cache. Check it on plain free output: total 12305676, available 11084272, the difference is 1221404, exactly what is printed under used. So used plus free plus buff/cache comes out larger than total, and nothing is broken.

Inside a container free shows the host memory, not the container limit. docker run -m 512m still prints total 11Gi, while /sys/fs/cgroup/memory.max in that same container answers 536870912. The OOM killer takes the process down at 512 megabytes with free still showing 10 gigabytes available. In a container read the cgroup, not free.

The units differ across three modes, so numbers from them are not comparable. With no flags free prints kibibytes, so 12305676 is 12 gigabytes and not 12 megabytes. free -h divides by 1024 and shows 11Gi; free -h --si divides by 1000 and shows 12G for the very same machine.

Used in

You need this in the lesson Monitoring. The theory is the chapter Monitoring and bottlenecks.

See also

The vmstat command, Load average, The /proc filesystem.

Try it

Open the sandbox: a real throwaway Linux terminal in your browser. Run the commands above by hand - the container is deleted when you leave.