free -mh

Please fully explain the purpose, history and output of this command: free -mh

The 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 free -mh:

Purpose

  1. Display Memory Usage: The primary purpose of free is 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.
  2. 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.

History

  • The free command 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 procps package, which is a set of command-line utilities that provide information about processes using the /proc filesystem.
  • The /proc filesystem is a special filesystem in Unix-like operating systems that provides information about the system and the processes running on it.

Output

When you run free -mh, the output typically includes several lines:

  1. Total: Total physical RAM available in the system.
  2. Used: Amount of RAM currently in use.
  3. Free: Amount of RAM not in use.
  4. Shared: Memory used (mostly) by tmpfs (Temporary File Storage system).
  5. Buff/Cache: Memory used by kernel buffers and cache.
  6. Available: Estimate of how much memory is available for starting new applications, without swapping.

Example Output

      total used free shared buff/cache available
Mem:  15G   3.2G 8.61013.3G       11G
Swap: 2.00B   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.

You should also read:

FreeIPA

Bose is the Chief Computer Scientist of a large technology company in Abuja, Nigeria. She wants to build a large GNU/Linux computer network…