How to Use the free Command to Monitor Memory on Linux


The free command is a useful tool for monitoring your Linux system’s memory usage. It provides a quick overview of the amount of free and used memory, helping you understand your system’s current state and troubleshoot performance issues effectively.

To display the current memory statistics, simply type:

free

This will show information about total, used, free, shared, buffer/cache, and available memory in the system, giving you a comprehensive snapshot of your system’s RAM usage more info.

If you need to see the memory in specific units such as Bytes, Kilobytes, Megabytes, or Gigabytes, you can append the relevant option:

  • For Bytes: free -b
  • For Kilobytes: free -k
  • For Megabytes: free -m
  • For Gigabytes: free -g

For example, to view memory in Megabytes, run:

free -m

Sometimes, the default output can be a bit quick to change, especially if you’re monitoring real-time activity. To make it easier to read, you can display the memory information in a human-readable format, which automatically adjusts the units to be more understandable:

free -h

This is extremely handy for quick assessments or when sharing data with others unfamiliar with raw numbers.

If you want to continuously monitor your memory usage over time, you can set free to refresh every few seconds. For example, to update every 2 seconds:

free -s 2

or

free —seconds=2

This allows you to observe how memory utilization varies dynamically, which can be especially useful during system stress testing or troubleshooting.

In summary, free is a simple yet powerful command to keep an eye on your system’s RAM. Whether you just need a quick check or ongoing monitoring, it’s a valuable part of your Linux toolkit.

See Also