Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

free

Display amount of free and used memory in the system.

Description

Displays the total amount of free and used physical and swap memory in the system, as well as the buffers and caches used by the kernel. The information is gathered from /proc/meminfo.

Inputs

  • /proc/meminfo – memory statistics including MemTotal, MemFree, MemAvailable, Buffers, Cached, SReclaimable, Shmem, SwapTotal, SwapFree, LowTotal, LowFree, HighTotal, HighFree, CommitLimit, Committed_AS

Arguments

Unit selection

These flags are mutually exclusive. If none is specified, the default unit is kibibytes (1024 bytes).

FlagUnitBase
-b, --bytesbytes
--kilokilobytes1000
--megamegabytes1000^2
--gigagigabytes1000^3
--teraterabytes1000^4
--petapetabytes1000^5
-k, --kibikibibytes (default)1024
-m, --mebimebibytes1024^2
-g, --gibigibibytes1024^3
--tebitebibytes1024^4
--pebipebibytes1024^5

Display options

FlagDescription
-h, --humanHuman-readable output with auto-scaled units
--siUse powers of 1000 instead of 1024 (with -h)
-w, --wideWide output: show separate Buffers and Cache columns instead of combined buff/cache
-l, --lohiShow detailed low and high memory statistics
-L, --lineShow output on a single line
-t, --totalShow a Total row (RAM + swap combined)
-v, --committedShow committed memory and commit limit

Repeat options

FlagDescription
-s, --seconds SECSRepeat printing every SECS seconds (accepts fractional values)
-c, --count NRepeat N times then exit (if used without -s, prints N times with no delay)

When -s is used without -c, repeats indefinitely. When both are used, repeats N times at the given interval.

Behavior

Default table mode

Produces a table with the following columns and rows:

              TOTAL    USED    FREE  SHARED  BUFF/CACHE  AVAILABLE
Mem:       16306960 5765432 2341528  803712     8200000   10541528
Swap:       8388604  123456 8265148

Columns:

  • TOTAL – total installed memory (or swap)
  • USED – used memory, calculated as: TOTAL - FREE - BUFFERS - CACHE
  • FREE – unused memory
  • SHARED – memory used by tmpfs (Shmem from meminfo)
  • BUFF/CACHE – sum of buffers and cache (includes SReclaimable)
  • AVAILABLE – estimate of memory available for starting new applications

Wide mode (-w)

Replaces the combined BUFF/CACHE column with separate BUFFERS and CACHE columns:

              TOTAL    USED    FREE  SHARED  BUFFERS    CACHE  AVAILABLE

Line mode (-L)

Prints all values on a single line:

SwapUse 123456 CachUse 8200000  MemUse 5765432 MemFree 2341528

Additional rows

  • -l, --lohi adds Low and High memory rows (relevant on 32-bit systems)
  • -t, --total adds a Total row summing Mem and Swap
  • -v, --committed adds a Comm row showing CommitLimit, Committed_AS, and the difference

Memory calculations

  • cached = Cached + SReclaimable (from meminfo)
  • used = MemTotal - MemFree - Buffers - cached
  • buff/cache = Buffers + cached
  • swap used = SwapTotal - SwapFree

Human-readable mode (-h)

Automatically selects the most appropriate unit (B, Ki, Mi, Gi, Ti, Pi) for each value. Values below 10 of the selected unit are shown with one decimal place. With --si, uses powers of 1000 and suffixes B, K, M, G, T, P.

Exit codes

CodeMeaning
0Success
1Failure (cannot read /proc/meminfo)

Divergences from procps-ng

  • Column headers are UPPERCASE (TOTAL, USED, FREE, SHARED, BUFF/CACHE, AVAILABLE) rather than lowercase, matching the convention used by lsblk, lscpu, and other modern util-linux tools.
  • Error messages for invalid arguments use different wording.