opscape

System and users

free

Show how much RAM and swap is in use, free, and available to new programs.

free [-h|-m|-g] [-w] [-t] [-s SECONDS [-c COUNT]]

10 of 10 examples run in Debian 13.7 on 2026-10-31 · procps 2:4.0.4-9 · manual: free(1)

free summarizes /proc/meminfo into a small table: total memory, what processes use, what the kernel holds as page cache and buffers, and what is left. The column to read is available, not free. Linux deliberately fills idle RAM with cached file data and gives it back the moment a program asks, so a low free figure on a healthy server is normal. available is the kernel's own estimate of how much memory a new workload could get without swapping.

Numbers are in kibibytes unless you pick a unit; -h chooses one per value and is what you want interactively. For scripts, use a fixed unit (-m, -b) and pick the column with awk, or read MemAvailable from /proc/meminfo directly.

The examples run in a container, which sees the host machine's memory, so the totals are large.

Examples

Show memory use in kibibytes

free
explain
output
               total        used        free      shared  buff/cache   available
Mem:       263772776   168448804    32880560      127516    64872520    95323972
Swap:        8388604     2131428     6257176

One row for RAM, one for swap. buff/cache is reclaimable cache; available is roughly free plus the part of that cache the kernel can drop, which is why it is far larger than free.

Show memory in readable units

free -h
explain
output
               total        used        free      shared  buff/cache   available
Mem:           251Gi       160Gi        31Gi       124Mi        61Gi        90Gi
Swap:          8.0Gi       2.0Gi       6.0Gi

-h picks a unit per value and suffixes it: Gi, Mi and so on are powers of 1024. This is the form to type at a prompt.

Use a fixed unit for comparison

free -m
explain
output
               total        used        free      shared  buff/cache   available
Mem:          257590      164526       32083         124       63352       93063
Swap:           8191        2081        6110

-m prints whole mebibytes in every cell, so values line up and stay parseable. -g uses gibibytes, but rounds small values down to 0, which hides detail.

Use powers of 1000 instead of 1024

free -h --si
explain
output
               total        used        free      shared  buff/cache   available
Mem:            270G        172G         33G        130M         66G         97G
Swap:           8.6G        2.2G        6.4G

With --si the suffixes become G and M and mean 10^9 and 10^6 bytes, matching how disk and RAM vendors label capacity. Without it, free uses binary units.

Split buffers and cache into separate columns

free -wh
explain
output
               total        used        free      shared     buffers       cache   available
Mem:           251Gi       160Gi        31Gi       124Mi       2.9Gi        59Gi        90Gi
Swap:          8.0Gi       2.0Gi       6.0Gi

-w (wide) shows buffers (block-device metadata) and cache (file contents) separately instead of the combined buff/cache column.

Add a total line for RAM plus swap

free -ht
explain
output
               total        used        free      shared  buff/cache   available
Mem:           251Gi       160Gi        31Gi       124Mi        61Gi        90Gi
Swap:          8.0Gi       2.0Gi       6.0Gi
Total:         259Gi       162Gi        37Gi

-t appends a Total: row that sums the memory and swap rows.

Sample memory a few times

free -h -s 1 -c 3
explain
output
               total        used        free      shared  buff/cache   available
Mem:           251Gi       160Gi        31Gi       124Mi        61Gi        90Gi
Swap:          8.0Gi       2.0Gi       6.0Gi

               total        used        free      shared  buff/cache   available
Mem:           251Gi       161Gi        30Gi       124Mi        61Gi        90Gi
Swap:          8.0Gi       2.0Gi       6.0Gi

               total        used        free      shared  buff/cache   available
Mem:           251Gi       161Gi        30Gi       124Mi        61Gi        90Gi
Swap:          8.0Gi       2.0Gi       6.0Gi

-s 1 repeats the report every second and -c 3 stops after three reports, each followed by a blank line. Without -c it runs until you press Ctrl-C.

Get available memory as a number for a script

free -m | awk '/^Mem:/ { print $7 }'
explain
output
92505

The seventh field of the Mem: line is available in mebibytes. Matching the row label rather than taking "line 2" keeps this working if other rows are added.

Read the same figures from /proc/meminfo

grep -E '^(MemTotal|MemFree|MemAvailable|SwapTotal)' /proc/meminfo
explain
output
MemTotal:       263772776 kB
MemFree:        32649300 kB
MemAvailable:   95092828 kB
SwapTotal:       8388604 kB

This file is where free gets its data, in kB. It has dozens more fields (dirty pages, huge pages, slab) when you need detail free does not show.

Print everything on one line

free -L
explain
output
SwapUse     2131428 CachUse    64872644  MemUse   168655796 MemFree    32673452 

-L puts swap used, cache used, memory used and memory free on a single line (in KiB), handy for appending to a log with a timestamp.

Common pitfalls

  • Treating the free column as headroom. Cache counts as used but is handed back on demand; watch available, and worry when it is low and swap activity (si/so in vmstat) is high.

  • free -g rounds down, so a machine with 900 MiB available shows 0. Use -h or -m when the numbers are small.

  • Inside a container free reports the host's memory, not the container's cgroup limit. Check /sys/fs/cgroup/memory.max for the limit that will actually trigger the OOM killer.

  • Old procps versions printed a -/+ buffers/cache line instead of available. Advice that tells you to read that line predates procps 3.3.10.

GNU vs BSD and macOS

The examples above ran the GNU/Linux version. These are the differences that matter on macOS and the BSDs (written from their documentation, not run here).

  • free is Linux-only (procps); macOS has no free command. Use vm_stat there, which reports page counts rather than bytes, or top -l 1 | head for a summary.

Options worth knowing

A selection, described in our own words. For the full list, see free(1) or free --help.

OptionWhat it does
-h, --humanShow each value with a readable unit suffix.
-b, --bytesShow values in bytes.
-k, --kibiShow values in kibibytes (the default).
-m, --mebiShow values in mebibytes.
-g, --gibiShow values in gibibytes, rounded down.
--siUse powers of 1000 instead of 1024.
--megaShow values in megabytes (10^6 bytes).
--gigaShow values in gigabytes (10^9 bytes).
-w, --wideShow buffers and cache in separate columns.
-t, --totalAdd a row with RAM and swap totals.
-L, --linePrint a compact single-line summary.
-l, --lohiShow low and high memory statistics.
-v, --committedShow committed memory and the commit limit.
-s, --seconds NRepeat the report every N seconds.
-c, --count NStop after N reports.
-V, --versionPrint the procps version and exit.

Related