Signup/Sign In
LAST UPDATED: MARCH 6, 2023

Free command in Linux

The free command in Linux is a simple yet powerful utility that displays information about the amount of free and used memory in a system. It provides details about the total amount of physical memory (RAM), the amount that's currently in use, and the amount that's available for use.

The free command is a quick and easy way to check the memory usage of a Linux system, and it can be particularly useful when diagnosing performance issues or when trying to optimize memory utilization. Understanding the output of the free command and interpreting the various metrics it provides can help you troubleshoot memory-related issues and improve the performance of your system.

Syntax:

$free [OPTION]

1

Free command options

  • -b: -bytes: Shows the RAM in bytes.
  • -k: -kilo: Shows the amount of memory in kilobytes (default). -m: -mega: Displays the memory size in megabytes.
  • -g, -giga: Displays the memory size in gigabytes.
  • - - tera: The amount of RAM is displayed in terabytes.
  • -h, -human: Displays all output columns automatically scaled to the smallest three-digit unit and the units of the printout. B (bytes), K (kilos), M (megas), G (gigas), and T are the units utilized (teras).

1. Using -b:

The output is only shown in unit bytes.

2

2. Using -k:

The result is shown in kilobytes.

3

3. Using -m:

The result is shown in megabytes.

4

4. Using -g:

Displays the result in gigabytes.

6

5. Using -t (total):

This option displays an additional line with the total, utilized, and free columns totaled.

7

6. Using -s and -o:

This option allows you to see the result of the free command after a user-specified time interval. This option accepts a numeric value that serves as the number of seconds after which the output will be presented.

8

Conclusion

The "free" command in Linux is an important tool for monitoring system memory usage. It provides detailed information about the total amount of available memory, as well as how much of it is being used and how much is available. By using the "free" command, you can quickly and easily determine if your system is experiencing a shortage of memory, which can impact system performance.

The "free" command is a valuable resource for anyone working with Linux systems, as it helps to ensure that system memory is being used effectively and efficiently. Whether you are a system administrator or a developer, understanding how to use the "free" command can help you optimize system performance and avoid potential issues related to memory usage.



About the author:
Pradeep has expertise in Linux, Go, Nginx, Apache, CyberSecurity, AppSec and various other technical areas. He has contributed to numerous publications and websites, providing his readers with insightful and informative content.