Read Linux Memory Pressure with free
You will use free to answer the useful first question about a Linux host: how much memory can a new program use without swapping? You will also learn how to choose units, separate cache from genuinely unavailable memory, and collect a finite series of readings. Allow about ten minutes. The examples are read-only and normally need no elevated privileges.
The route
Jump straight to the step you need, or tick off Done means at the end.
1. Check the installed command
free is part of the procps package. This guide follows procps-ng 4.0.4, installed here as Ubuntu package version 2:4.0.4-4ubuntu3.3. Other releases may add or format options differently, so check the local binary before copying a script between distributions.
$ command -v free
/usr/bin/free
$ free --version
free from procps-ng 4.0.4
Checkpoint: if command -v finds nothing, install the procps package through your normal distribution process. Do not use sudo just to read memory statistics.
2. Read the default report
Run the command with no options first:
$ free
total used free shared buff/cache available
Mem: 32644620 11279188 1206276 1543796 22342540 21365432
Swap: 16759804 799328 15960476
The exact numbers are host-specific and will change while programs run. The default unit is kibibytes, despite the short column width and the traditional command name. total is usable physical or swap memory after a small amount is reserved. used is calculated as total - available, not simply total minus the column labelled free. free is currently unused memory. shared is mostly memory used by tmpfs.
buff/cache combines kernel buffers with page cache and reclaimable slabs. It can often be reclaimed when an application needs space. available is the most useful quick capacity estimate: it includes reclaimable cache and accounts for memory that cannot all be reclaimed. Treat it as an estimate, not a reservation or a guarantee that every allocation will succeed.
For the same reason, a small free value alone does not prove that a host is out of RAM. Start with available, then investigate swap activity, process usage and workload behaviour if it is low or falling.
3. Pick units deliberately
Use human-readable output for an interactive check:
$ free --human
total used free shared buff/cache available
Mem: 31Gi 10Gi 1.2Gi 1.5Gi 21Gi 20Gi
Swap: 15Gi 780Mi 15Gi
--human scales each field and prints binary units such as Ki, Mi and Gi. It is easy to read, but the rounding makes it a poor choice for machine comparisons. Use --bytes for exact byte values, or use an explicit binary unit such as --mebi or --gibi:
$ free --bytes
$ free --mebi
$ free --gibi
Short forms are available: -b, -m and -g. The longer names make one-off commands and reviewed scripts clearer. Do not confuse binary units with SI units. --mega uses megabytes based on powers of 1000; --mebi uses mebibytes based on powers of 1024. --si changes the unit family used by human-readable output to kilo, mega and giga based on powers of 1000.
Checkpoint: for a monitoring script, choose one unit and keep it fixed. For a human inspection, use free -h and record the command and timestamp alongside any numbers you report.
4. Separate buffers and cache when diagnosing pressure
The normal report joins buffers and cache to keep the output compact. Add --wide when you need to see them separately:
$ free --wide --human
total used free shared buffers cache available
Mem: 31Gi 10Gi 1.2Gi 1.5Gi 2.3Gi 19Gi 20Gi
Swap: 15Gi 780Mi 15Gi
This is a reporting change only. It does not clear cache, reclaim memory or alter the kernel. Avoid advice that starts with deleting files under /proc or forcing cache drops. Those are different, disruptive operations and are not required to use free.
5. Add totals or low and high memory details
Use --total when the combined RAM and swap figures are useful:
$ free --human --total
total used free shared buff/cache available
Mem: 31Gi 10Gi 1.2Gi 1.5Gi 21Gi 20Gi
Swap: 15Gi 780Mi 15Gi
Total: 47Gi 11Gi 16Gi
The total line adds the memory and swap rows. It is a capacity view, not a claim that all swap is as fast or as suitable as RAM. A system with plenty of combined capacity can still be under pressure if it is actively swapping.
On systems where low and high memory statistics are relevant, --lohi adds Low and High rows. Modern 64-bit hosts commonly show no high memory, so a row of zeroes can be normal:
$ free --lohi --human
Low: 31Gi 29Gi 1.2Gi
High: 0B 0B 0B
6. Take a finite series of readings
--seconds repeats the report after a delay. By itself it continues until interrupted. Add --count when you want a bounded command that can finish in a script:
$ free --human --seconds 1 --count 3
total used free shared buff/cache available
Mem: 31Gi 10Gi 1.2Gi 1.5Gi 21Gi 20Gi
Swap: 15Gi 780Mi 15Gi
[two more readings follow]
The installed manual requires --count to be used with --seconds. The delay accepts floating-point values, so 0.5 is valid. For a compact log line, add --line, but retain a timestamp from the surrounding script because free does not add one for you.
If you omit --count, stop the repeating command with Ctrl-C. That only ends free; it does not undo or alter anything on the host.
7. Check commit information only when it matters
--committed adds a Comm row for the memory commit limit and committed or uncommitted amount. The manual says this row is relevant when memory overcommit is disabled. Its values can look surprising, including a negative third column, so do not add it to a routine RAM dashboard without understanding the kernel policy:
$ free --committed --human
Comm: 31Gi 42Gi -11Gi
This option reports another view of accounting; it does not enable or disable overcommit and does not change the commit limit. If you need the underlying fields, free reads /proc/meminfo. Compare readings from the same host and kernel rather than treating one snapshot as a universal threshold.
Common traps
- Do not call the
freecolumn "available". Use the explicitly labelledavailablecolumn for the estimate of memory usable without swapping. - Do not compare
free -houtput as if it were exact. Rounding and changing units can hide small movements. - Do not treat swap capacity as extra RAM. Check whether swap usage is growing and whether the workload is slowing.
- Do not run the command with
sudoby habit. Reading/proc/meminfois ordinarily permitted to an unprivileged user. - Do not parse aligned columns from a human report if a stable unit and explicit field handling are required. Confirm the exact procps version and test the parser against the hosts it will monitor.
Done means
- You identified the installed procps-ng version.
- You can explain why
availableis more useful thanfreefor a first pressure check. - You chose binary or SI units deliberately and know when rounding matters.
- You can collect a bounded series with
--secondsand--count. - You have made no configuration, cache, service or permission changes.