You are currently viewing Linux Commands – free

Linux Commands – free

Linux Commands – free

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have discussed df command in Linux which is used to get file system disk space usage.

https://cloudaffaire.com/linux-commands-df/

In this blog post, we will discuss free command in Linux. free command is used to display current system memory usage. By default, free command 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 information 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, 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
  • available: Estimation of how much memory is available for starting new applications, without swapping.

Linux Commands – free:

You can use free command to get current memory and swap utilization. By default, memory usage is printed in units of 1024 bytes (kibibytes), but this can be overridden with different options.

You can use free -h or –human options to show all output fields automatically scaled to the shortest three digit unit and display the units of print out. The following units are used.

  • B = bytes
  • Ki = kibibyte (1024 bytes)
  • Mi = mebibyte (1024 kibibyte)
  • Gi = gibibyte (1024 mebibyte)
  • Ti = tebibyte (1024 gibibyte)
  • Pi = pebibyte (1024 tebibyte)

You can use free -w or –wide options to switch to the wide mode which produces lines longer than 80 characters. In wide mode buffers and cache are reported in two separate columns.

You can use free -l or –lohi options to show detailed low and high memory statistics.

You can use free -t or –total options to display a line showing the column totals.

You can use free -s or –seconds delay options to continuously display the result delay seconds apart. You may actually specify any floating-point number for delay using either . or , for the decimal point. You can use -c or –count options with -s delay option to display the result count times every delay seconds.

free command provides lots of options to control the size units in the output. Below is the list of all available size options in free command.

  • -b, –bytes: Display the amount of memory in byt
  • –kibi: Display the amount of memory in kibibytes. (default)
  • –mebi: Display the amount of memory in mebibyt
  • –gibi: Display the amount of memory in gibibyt
  • –tebi: Display the amount of memory in tebibyt
  • –pebi: Display the amount of memory in pebibytes.
  • –si: Display in power of 1000 instead power of 1024
  • –kilo: Display the amount of memory in kilobytes. Implies –si
  • –mega: Display the amount of memory in megabytes. Implies –si
  • –giga: Display the amount of memory in gigabytes. Implies –si
  • –tera: Display the amount of memory in terabytes. Implies –si
  • –peta: Display the amount of memory in petabytes. Implies –si

Hope you have enjoyed this article. In the next blog post, we will discuss crontab command in Linux.

 

Leave a Reply