free (Display memory usage)
The free command provides a summary of the total, used, and available physical memory (RAM) and swap memory in the system. It is one of the first tools used to diagnose performance issues and OOM (Out Of Memory) errors.
1. Basic Usage
free [options]
2. Key Options
| Option | Name | Description |
|---|---|---|
-h |
human-readable | Displays the output in an easily readable format (GB, MB). |
-m |
megabytes | Displays the amount of memory in mebibytes. |
-g |
gigabytes | Displays the amount of memory in gibibytes. |
-s N |
seconds | Continuously displays the statistics every N seconds. |
-t |
total | Adds a line showing the column totals. |
3. Practical Examples
① Quick check of memory health
free -h
② Monitoring memory leaks in real-time
free -h -s 5
4. [Tip] Understanding "Available" Memory
Don't be alarmed if the free column shows a very small number. Linux uses unused memory for caching (buff/cache). The available column is the most accurate indicator of how much memory can be allocated to new applications without causing the system to swap.