Free command with examples to viewing memory usage in Linux

12 Free command examples for viewing memory usage in Linux like operating systems

Free command is a simple and very easy command for checking the total amount of free and used memory (physical and swap both) in the system with buffers and caches used by the kernel in Linux/Unix.In this article, I will show you how to use “free” command with all its options to check memory usage on Linux.

1.) View amount of free and used memory in the Linux system

free
              total        used        free      shared  buff/cache   available
Mem:        1867248     1190176       92100       33796      584972      453492
Swap:       2097148         116     2097032

By default, free command will show you memory information in Kilo Bytes (KB)

Where,
total – total memory installed in the system.
used – memory in-use by the system
free – unused memory in-use by the system
shared – It is the memory mostly used by the tmpfs
buff/cache – It is the Sum of memory used by the buffers and cache
available – available show us the estimated amount of memory which is available to start new applications without swapping.

Output
Free command output Linux

2.) View memory in human-readable output

-h option shows us the memory in human readable form.

free -h
              total        used        free      shared  buff/cache   available
Mem:           1.8G        1.1G         76M         47M        582M        414M
Swap:          2.0G        132K        2.0G

3.) View memory in Bytes

Use option as -b, For viewing size of the memory in Bytes (B).

free -b
              total        used        free      shared  buff/cache   available
Mem:     1912061952  1227964416    99573760    58458112   584523776   420175872
Swap:    2147479552      200704  2147278848

4.) View memory in Kilo Bytes

-k option will show you memory information in Kilo Bytes (KB)

free -k
              total        used        free      shared  buff/cache   available
Mem:        1867248     1199284       96976       57088      570988      410212
Swap:       2097148         196     2096952

5.) View memory in Megabytes

Use option as -m, For viewing size of the memory in Megabytes (MB).

free -m
              total        used        free      shared  buff/cache   available
Mem:           1823        1171          94          55         557         400
Swap:          2047           0        2047

6.) View memory in Gigabytes

free -g
              total        used        free      shared  buff/cache   available
Mem:              1           1           0           0           0           0
Swap:             1           0           1

7.) Display a line with column totals

free -t
              total        used        free      shared  buff/cache   available
Mem:        1867248     1187084      108756       57088      571408      422360
Swap:       2097148         196     2096952
Total:      3964396     1187280     2205708

8.) Wide Mode

This option displays buffers and cache in two separate columns.

[[email protected] ~]# free -w
              total        used        free      shared     buffers       cache   available
Mem:        1867248     1208316       87328       57088         108      571496      401108
Swap:       2097148         196     2096952

9.) View low and high memory statistics.

free command with -l option shows you low and high memory statistics.

free -l
              total        used        free      shared  buff/cache   available
Mem:        1867248     1196668       92392       60628      578188      409120
Low:        1867248     1774856       92392
High:             0           0           0
Swap:       2097148         196     2096952

10.) Display information every N seconds

This command will display updated free every 10 seconds.

free -s 10
              total        used        free      shared  buff/cache   available
Mem:        1867248     1224852       82336       95560      560060      314264
Swap:       2097148         304     2096844

              total        used        free      shared  buff/cache   available
Mem:        1867248     1220272       86852       95560      560124      318844
Swap:       2097148         304     2096844

11.) Free Command Help

This will show you options which can be used with free command

free --help

Output
free command example output

12.) Check Free Command Version

-V option will display free command version information.

free -V
free from procps-ng 3.3.10

If you have any questions? Leave a comment below, or you can contact me using the contact us page.

Add Comment