free Command: Tutorial & Examples
Display information about free and used memory
The free
command is used to display information about the system's memory usage. It shows the total amount of physical memory (RAM) available on the system, as well as the amount
of memory that is being used and the amount that is available.
Here is an example of the free command and its output:
free
total used free shared buff/cache available
Mem: 16335456 8479144 992180 144948 5545132 7048004
Swap: 8388604 0 8388604
The output is divided into three sections:
The first row shows the total amount of physical memory, the amount that is being used, and the amount that is available. After that, the amount of memory that is being used for caching and buffering is displayed. The second row shows the total amount of swap space (virtual memory), the amount that is being used, and the amount that is available.
The free
command can be useful for identifying memory-related performance issues on a Linux system. If the amount of used memory is consistently high and there is little available
memory, it may be necessary to add more physical memory to the system or to optimize the system's memory usage.
To display the memory usage in a more compact format, you can use the -m
flag to show the values in megabytes, or the -k
flag to show the values in kilobytes. You can also use the
-t
flag to display a summary of the total memory usage.
free -mt
total used free shared buff/cache available
Mem: 15968 8287 964 14 6706 7096
Swap: 8192 0 8192
Total: 24160 8287 9184