Linux Free Command: Memory Metrics Explained
The free command is a fundamental Linux utility designed
to display a fast, real-time snapshot of system memory usage, including
both physical RAM and swap space. This article breaks down the metrics
reported by the command—specifically detailing the columns for total,
used, free, shared, buffer/cache, and available memory—to help
administrators accurately assess memory consumption and avoid common
misinterpretations regarding Linux memory management.
Standard Output Overview
When you run free without any flags, it reports values
in kibibytes (KiB). To make the values easier to read, it is commonly
executed with the human-readable flag:
free -hA typical output displays two primary rows:
- Mem: Represents physical RAM.
- Swap: Represents swap space, which is virtual memory stored on a drive partition or file used when physical RAM is under pressure.
The Memory Metrics Columns
The output organizes data into several distinct columns:
- total: The total amount of physical RAM or swap space installed on the system, excluding a small amount reserved by the kernel at boot.
- used: Memory currently consumed by running
processes. In modern versions of
procps, this is calculated astotal - free - buff/cache. - free: Memory that is completely unallocated and idle. In Linux, a low "free" value is normal and expected because the kernel proactively utilizes unused RAM for performance optimization.
- shared: Memory utilized primarily by
tmpfs(ramfs filesystems) and shared memory mechanisms (e.g., inter-process communication). - buff/cache: The combined memory allocated to kernel
buffers and page cache.
- Buffers: Temporary storage for raw disk blocks waiting to be written or read, smoothing out disk I/O.
- Cache: Cached files recently read from storage. This memory can be reclaimed almost instantly if an application requests more memory.
- available: An estimate of how much memory is available for starting new applications without causing the system to swap. Unlike the "free" column, "available" takes into account that most of the page cache and memory slices can be freed immediately if needed. This is the most critical metric for assessing memory pressure.
Common Command Options
-b,-k,-m,-g: Display amounts in bytes, kibibytes, megabytes, or gigabytes.-h: Formats the output using the shortest, human-readable units (e.g., GiB, MiB).-t: Adds a "Total" row combining physical RAM and swap metrics.-s [seconds]: Continuously updates the display at the specified interval.
Interpreting Memory Health
A common misconception among new Linux administrators is believing
the system is running out of memory when the free column
drops near zero. Linux uses idle memory for caches to speed up
operations. Memory health should primarily be evaluated using the
available column (for headroom) and the
used metric in the Swap row (to see if the system is
heavily relying on slower disk-backed memory).