Home / Alt manpages / free(1)

  • free(1)
  • User command
  • linux

Read Linux Memory Pressure with free

The free column says 1.2 GiB and you are ready to panic. Don't: that column is the wrong number to look at. This guide uses free to answer the question that matters, how much memory a new program can use without swapping, and covers units, cache versus genuinely unavailable memory, and finite series of readings. Allow about ten minutes. The examples are read-only and normally need no elevated privileges.

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 the usual way for your distribution. 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 numbers are host-specific and change as programs run. The default unit is kibibytes, despite the narrow column width and the traditional command name. Column by column:

  • 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 memory that is currently unused.
  • 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 available as an estimate, not a reservation or a guarantee that every allocation will succeed.

Tip

A small free value alone does not prove the host is out of RAM. Start with available, then look at 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 reads well, but the rounding makes it a poor choice for machine comparisons. Use --bytes for exact byte values, or an explicit binary unit such as --mebi or --gibi:

$ free --bytes
$ free --mebi
$ free --gibi

Short forms exist: -b, -m and -g. The long names make one-off commands and reviewed scripts clearer.

  • Binary is not SI. --mega uses megabytes based on powers of 1000; --mebi uses mebibytes based on powers of 1024.
  • --si switches families. It makes human-readable output use kilo, mega and giga based on powers of 1000.

Checkpoint

In 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. Split buffers from cache

The normal report joins buffers and cache to stay compact. Add --wide when you need 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 changes the report only. It does not clear cache, reclaim memory or alter the kernel.

Warning

Ignore advice that starts with deleting files under /proc or forcing cache drops. Those are different, disruptive operations, and you do not need them to use free.

5. Add totals or low and high memory

Use --total when combined RAM and swap figures help:

$ 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.

Where low and high memory statistics apply, --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. On its own it runs until interrupted. Add --count for a bounded command that can finish inside 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 keep a timestamp from the surrounding script, because free does not add one.

Tip

If you leave out --count, stop the repeating command with Ctrl-C. That only ends free; nothing on the host is undone or altered.

7. Check commit information only when it matters

--committed adds a Comm row for the memory commit limit and the committed or uncommitted amount. The manual says it matters when memory overcommit is disabled. The values can look odd, including a negative third column, so do not add it to a routine RAM dashboard until you understand the kernel policy:

$ free --committed --human
Comm:           31Gi        42Gi       -11Gi

This is another accounting view. 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, not one snapshot against a universal threshold.

Common traps

  • Wrong column. Do not call the free column "available". Use the explicitly labelled available column for the estimate of memory usable without swapping.
  • Rounded numbers. Do not compare free -h output as if it were exact. Rounding and changing units can hide small movements.
  • Swap is not RAM. Check whether swap usage is growing and whether the workload is slowing.
  • Habitual sudo. Reading /proc/meminfo is ordinarily permitted to an unprivileged user.
  • Fragile parsing. Do not parse aligned columns from a human report if you need a stable unit and explicit field handling. Confirm the exact procps version and test the parser against every host it will monitor.

Done means

  • Version known. You identified the installed procps-ng version.
  • Right column. You can explain why available beats free for a first pressure check.
  • Units chosen. You picked binary or SI units deliberately and know when rounding matters.
  • Bounded readings. You can collect a fixed series with --seconds and --count.
  • Nothing changed. You made no configuration, cache, service or permission changes.