Please fully explain the purpose, history and output of this command: free -mh
free command in Unix and Linux operating systems is a simple, yet powerful tool used for displaying the amount of free and used memory in the system. The command provides a quick snapshot of the system's memory usage, including both physical RAM and swap space. Here's a breakdown of the command
- Display Memory Usage: The primary purpose of
freeis to show 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.
- Options Used:
-m: Displays the memory information in megabytes.
-h: Human-readable format. It makes the output more readable by converting bytes into kilobytes (K), megabytes (M), gigabytes (G), etc.
freecommand has been a part of Unix-like systems for many years, evolving over time with different versions of Linux and Unix.
- It is part of the
procpspackage, which is a set of command-line utilities that provide information about processes using the
/procfilesystem is a special filesystem in Unix-like operating systems that provides information about the system and the processes running on it.
When you run
free -mh, the output typically includes several lines:
- Total: Total physical RAM available in the system.
- Used: Amount of RAM currently in use.
- Free: Amount of RAM not in use.
- Shared: Memory used (mostly) by tmpfs (Temporary File Storage system).
- Buff/Cache: Memory used by kernel buffers and cache.
- Available: Estimate of how much memory is available for starting new applications, without swapping.
total used free shared buff/cache available
Mem: 15G 3.2G 8.6G 101M 3.3G 11G
Swap: 2.0G 0B 2.0G
In this example:
- The system has 15 GB of total RAM.
- 3.2 GB is currently used by processes.
- 8.6 GB is free.
- 101 MB is shared.
- 3.3 GB is used as buffers/cache.
- 11 GB is available for new processes.
- The system also has 2 GB of swap space, which is currently not in use.
This command is especially useful for system administrators and power users to monitor and manage the memory usage of their systems.