The free
command is a powerful utility for monitoring memory usage on Linux systems. It provides detailed information about the total amount of memory available, used, and free on the system, as well as swap usage. In this article, we will explore how to use the free
command to display memory statistics on a Linux system.
When you run the free
command without any arguments, it will display memory statistics in kilobytes. The output will look something like this:
total used free shared buff/cache available
Mem: 16385692 4426388 7912212 282888 4045092 10988616
Swap: 4194300 0 4194300
Here’s a breakdown of what each column represents:
total
: the total amount of physical memory available on the systemused
: the amount of memory currently in usefree
: the amount of memory that is not being used by any processshared
: the amount of memory shared between processesbuff/cache
: the amount of memory used for buffers and cacheavailable
: an estimate of how much memory is available for starting new applications
If you want to display the memory statistics in a more human-readable format, you can use the -h
option with the free
command. This will output the memory usage in gigabytes, megabytes, or kilobytes depending on the size of the memory:
total used free shared buff/cache available
Mem: 15G 4G 7G 276M 3G 10G
Swap: 4G 0 4G
You can also use the -b
, -k
, -m
, or -g
options to display memory statistics in bytes, kilobytes, megabytes, or gigabytes respectively. For example, to display memory statistics in megabytes, you can use the following command:
free -m
In addition to displaying memory statistics, the free
command also provides information on swap usage. Swap is a space on the hard drive that is used by the operating system as virtual memory when the physical memory (RAM) is full. The free
command displays the total amount of swap space, used swap space, and free swap space on the system. If the used swap space is constantly high, it may indicate that the system is running out of physical memory and is relying heavily on swap space.
In conclusion, the free
command is a valuable tool for monitoring memory usage on Linux systems. By using this command, administrators can quickly check memory statistics and identify any issues related to memory usage on the system. Whether you need to check the total amount of memory available, monitor swap usage, or analyze memory trends over time, the free
command has got you covered.