Skip to content
Tutorials Center
My learning

Topics

Linux Command Reference ยท Processes and Signals

Linux free command

Reference for the Linux free command: read total, used, free, buff/cache and available memory, choose units with -h and -m, and understand why free looks low.

free shows how much physical memory and swap the system has, how much is in use, and how much is available. It reads the kernel's counters from /proc/meminfo and presents them as a small table.

The most common mistake with free is reading the "free" column. Linux deliberately uses spare memory as a disk cache, so a healthy, busy system shows very little free memory. The column that answers "how much can programs still get?" is available.

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

Try it

Bash Reading the table

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash Computing percentages yourself

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Terminal
free [options]
Option Description
-b, -k, -m, -g Show bytes, kibibytes (default), mebibytes or gibibytes.
--kilo, --mega, --giga Same, but powers of 1000. --si uses 1000 for all units.
-h, --human Pick a readable unit for each number (1.2Gi).
-w, --wide Show buffers and cache in separate columns instead of one buff/cache.
-t, --total Add a line with the totals of RAM plus swap.
-s N, --seconds N Repeat every N seconds until interrupted.
-c N, --count N With -s, stop after N samples.
-l, --lohi Show low and high memory statistics (rarely useful on 64-bit systems).
Column Meaning
total Installed memory that the kernel can use.
used total minus free, buffers and cache (in newer procps versions).
free Memory that is completely unused.
shared Memory used mainly by tmpfs and shared memory.
buff/cache Memory holding file data and block-device metadata. Most of it is released when programs need memory.
available The kernel's estimate of memory that new programs can get without swapping.

Returns: 0 on success. Reads are cheap and safe at any time.

Usage notes

  • Judge by available. Free memory near zero is normal; available memory near zero is the real warning. A server with 200 MiB free and 9 GiB available is fine.
  • Swap activity matters more than swap size. A little swap in use is harmless. Constantly moving pages in and out (see si and so in vmstat) is what slows a system down.
  • Old versions differ. Before procps-ng 3.3.10 there was an extra -/+ buffers/cache line and no available column. Scripts that parse free output should be tested on the target distribution.
  • -h is for people. Rounding hides small changes. Parse the plain output with -k or -b in scripts, or read /proc/meminfo directly.
  • Containers. Inside a container free still shows the host's memory, because /proc/meminfo is not namespaced by default. The container's real limit is in the cgroup files, for example /sys/fs/cgroup/memory.max. See Namespaces and cgroups.
  • Not per process. To find which process uses memory, use ps (ps aux --sort=-%mem | head) or top.
  • Dropping caches (echo 3 > /proc/sys/vm/drop_caches, as root) is almost never useful in production: the cache is a benefit, and it simply refills.
  • Watch mode. free -h -s 5 prints a new table every five seconds; watch free -h redraws in place.