Table of Contents
In this article, we are going to look at the 12 Practical and Useful free command examples frequently used in Linux (RHEL/CentOS 7/8). free
command is an open source utility frequently used in Linux Based Servers to display the total amount of free and used physical and swap memory in the System. It parses all the values from /proc/meminfo
file. We will see the usage of free
command in detail with examples in below sections.
SYNOPSIS
free [options]
free command examples in Linux
Also Read: 10 Simple and Useful ntpdate command examples in Linux(RHEL/CentOS 7/8)
Example 1: How to Check free command version in Linux
If you want to check free
command version then you need to use free -V
command as shown below.
[root@localhost ~]# free -V free from procps-ng 3.3.10
-V : Display version information.
Example 2: How to Check Free Memory in bytes
If you are looking to check free memory and used memory details in bytes
then you need to use free -b
command as shown below.
[root@localhost ~]# free -b total used free shared buff/cache available Mem: 2933882880 318574592 2472501248 8978432 142807040 2460704768 Swap: 2147479552 0 2147479552
-b : Display the amount of memory in bytes. More on free command Man Page.
total : Total installed memory.
used : Used memory (calculated as total - free - buffers - cache)
free : Unused memory (MemFree and SwapFree in /proc/meminfo).
shared : Memory used (mostly) by tmpfs.
cache : Memory used by the page cache and slabs.
buff/cache : Sum of buffers and cache.
available : Estimation of how much memory is available for starting new applications, without swapping.
Example 3: How to List Free Memory Details in kilobytes
If you are looking to check free memory and used memory details in kilobytes
then you need to use free -k
command as shown below.
[root@localhost ~]# free -k total used free shared buff/cache available Mem: 2865120 310932 2414704 8768 139484 2403208 Swap: 2097148 0 2097148
-k : Display the amount of memory in kilobytes. This is the default. More on free command Man Page.
Example 4: How to Display Free Memory information in Megabytes
If you are looking to check free memory and used memory details along with the swap usage in megabytes
then you need to use free -m
command as shown below.
[root@localhost ~]# free -m total used free shared buff/cache available Mem: 2797 303 2358 8 136 2347 Swap: 2047 0 2047
-m : Display the amount of memory in megabytes. More on free command Man Page.
Example 5: How to Check Free Memory in Gigabytes
If you are looking to check free memory and used memory details in gigabytes
then you need to use free -g
command as shown below.
[root@localhost ~]# free -g total used free shared buff/cache available Mem: 2 0 2 0 0 2 Swap: 1 0 1
-g : Display the amount of memory in gigabytes. More on free command Man Page.
Example 6: How to Check Free Memory in Human Readable Format
If you want to check free memory stats in human readable format then you need to use free -h
command as shown below.
[root@localhost ~]# free -h total used free shared buff/cache available Mem: 2.7G 303M 2.3G 8.6M 136M 2.3G Swap: 2.0G 0B 2.0G
-h : Show all output fields automatically scaled to shortest three digit unit and display the units of print out. More on free command Man Page.
Example 7: How to Check low and high memory Stats in Detail
If you want to check low and high memory stats in detail then you need to use free -l
command as shown below.
[root@localhost ~]# free -l total used free shared buff/cache available Mem: 2865120 310932 2414700 8768 139488 2403208 Low: 2865120 450420 2414700 High: 0 0 0 Swap: 2097148 0 2097148
-l : Show detailed low and high memory statistics. More on free command Man Page.
Example 8: How to Show Total Memory in Linux in Gigabytes
If you want to show total memory which includes physical memory and swap space in gigabytes then you need to use free -t -g command as shown below.
[root@localhost ~]# free -t -g total used free shared buff/cache available Mem: 2 0 2 0 0 2 Swap: 1 0 1 Total: 4 0 4
-t : Display a line showing the column totals.
-g : Display the amount of memory in gigabytes.
Example 9: How to Display Free Memory Stats After Every N Seconds
If you want to display free command stats after every N
seconds then you need to use free -s N
command as shown below. Since here we are trying to display continuous stats after every 3 seconds
then you need to use free -s 3
command as shown below.
[root@localhost ~]# free -s 3 total used free shared buff/cache available Mem: 2865120 311092 2414540 8768 139488 2403048 Swap: 2097148 0 2097148 total used free shared buff/cache available Mem: 2865120 311092 2414540 8768 139488 2403048 Swap: 2097148 0 2097148 total used free shared buff/cache available Mem: 2865120 311092 2414540 8768 139488 2403048 Swap: 2097148 0 2097148
-s : Continuously display the result delay seconds apart.
Example 10: How to Show wide output of free command in Linux
If you want to show the wide output of free command then you need to use free -w
command as shown below. Here you will see buffers and cache output separately as compared to previous shown examples.
[root@localhost ~]# free -w total used free shared buffers cache available Mem: 2865120 310984 2414640 8768 2116 137380 2403152 Swap: 2097148 0 2097148
-w : Switch to the wide mode.
Example 11: How to Check all the available options of free command in Linux
If you want to check all the options available with free command then you need to use free --help
command as shown below.
[root@localhost ~]# free --help Usage: free [options] Options: -b, --bytes show output in bytes -k, --kilo show output in kilobytes -m, --mega show output in megabytes -g, --giga show output in gigabytes --tera show output in terabytes --peta show output in petabytes -h, --human show human-readable output --si use powers of 1000 not 1024
Example 12: How to Check Man Page of free command in Linux
If you want to check the man page of free command then you need to use man free
command as shown below.
[root@localhost ~]# man free FREE(1) User Commands FREE(1) NAME free - Display amount of free and used memory in the system SYNOPSIS free [options] DESCRIPTION free displays the total amount of free and used physical and swap memory in the system, as well as the buffers and caches used by the kernel. The informa‐ tion is gathered by parsing /proc/meminfo. The displayed columns are: 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) 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 (Cached and SReclaimable in /proc/meminfo) buff/cache Sum of buffers and cache