How to check free memory in Linux commandline. This tutorial explains free command in Linux with options and examples.
Free Command In Linux With Options And Examples
The free command is used to display the total amount of free and used physical and swap memory on the system. It also displays the buffers and caches used by the kernel. The information displayed by the free command is gathered by parsing /proc/meminfo.
The output of the free command is displayed in the following columns:
- total: Total installed memory (MemTotal and SwapTotal in /proc/meminfo)
- used: Used memory (calculated as total – free – buffers – cache)
- free: Unused memory (MemFree and SwapFree in /proc/meminfo)
- available: Estimation of how much memory is available for starting new applications, without swapping.
- shared Memory used (mostly) by tmpfs (Shmem in /proc/meminfo, available on kernels 2.6.32, displayed as zero if not available)
- buffers: Memory used by kernel buffers (Buffers in /proc/meminfo)
- cache: Memory used by the page cache and slabs
- buff/cache: Sum of buffers and cache
How To Use The Free Command In Linux
Now let us learn about how to use the free command in Linux with options and examples.
The syntax for the free command is as follows:
free [OPTIONS]
When used without any option, the free command will display information about the memory and swap in kibibyte.
free
NOTE: kibibyte is a unit of measurement of computer information consisting of 1,024 bytes. 1 kibibyte (KiB) is 1024 bytes. A kilobyte and a kibibyte are not the same. A kilobyte represents 1,000 bytes whereas a kibibyte (KiB) represents 1,024 bytes.
Free is one of the Linux commands to check ram size in gb. This command can be used to show memory usage in human readable format.
By default, the free command displays the memory information in kibibyte (see above- what is kibibyte). To view the same information in human-readable format (megabytes and gigabytes), use the -h option with free command:
For example, to show the output in megabytes, you would run the following command:
free --mega
Free command can also be used to show the memory usage in other metrics – the unit in which the memory is measured. The various options are:
- -b, –bytes – Display output in bytes.
- –kilo – Display output in kilobytes (1KB = 1000bytes).
- –mega – Display output in megabytes.
- –giga – Display output in gigabytes.
- –tera – Display output in terabytes.
- -k, –kibi – Display output in kibibytes. (1KiB = 1024bytes). This is the default unit.
- -m, –mebi – Display output in mebibytes.
- -g, –gibi – Display output in gibytes.
- –tebi – Display output in tebibytes.
- –peti – Display output in pebibytes.
- –si – Instead of 1024, use powers of 1000. For example –mebi –si is equal to –mega.
That’s all. This tutorial has shown you how to use the free command to check the system’s memory usage in your terminal.