Lesson 65: free Command
In this lesson, you'll learn how to use the free command to check physical and swap memory usage in Linux.
The Linux free command gives information about the total used and available space of physical memory and swap memory, with buffers used by the kernel in Linux/Unix-like operating systems.
Let's look at some useful examples of free commands with options that might be useful for you to better utilize the memory that you have.
free Command Syntax
# free [OPTIONS]
free Command Options
| Option | Description |
|---|---|
-b |
Display memory size in Bytes |
-k |
Display memory size in Kilobytes (default) |
-m |
Display memory size in Megabytes |
-g |
Display memory size in Gigabytes |
-t |
Display a total line at the end of the output |
-o |
Disable the display of the buffer-adjusted line |
-s N |
Update the output every N seconds |
-l |
Display detailed high and low memory size statistics |
-V |
Display the free command version information |
1. Display System Memory
The free command is used to check the used and available space of physical memory and swap memory in KB. See the command in action below.
# free
total used free shared buffers cached
Mem: 1021628 912548 109080 0 120368 655548
-/+ buffers/cache: 136632 884996
Swap: 4194296 0 4194296
2. Display Memory in Bytes
The free command with option -b displays the size of memory in Bytes.
# free -b
total used free shared buffers cached
Mem: 1046147072 934420480 111726592 0 123256832 671281152
-/+ buffers/cache: 139882496 906264576
Swap: 4294959104 0 4294959104