free

2024-03-01

Decoding the free Command’s Output

The simplest way to use the free command is to type free into your terminal. This will display a table summarizing memory usage. Let’s break down the key columns:

Example:

A typical output might look like this:

              total        used        free      shared  buff/cache   available
Mem:           993M        214M        631M        160M        147M        736M
Swap:         2002M         51M       1951M

This indicates a system with 993MB of RAM, where 214MB is used, 631MB is free, 160MB is shared between processes, 147MB is in buffers and cache, and 736MB is immediately available. The system also has 2002MB of swap space, with 51MB currently used.

Enhancing the free Command with Options

The free command offers many options to customize its output:

Code Examples with Options:

  1. Human-readable output:
free -h
  1. Output in Gigabytes:
free -g
  1. Continuous monitoring every 2 seconds:
free -h -s 2

This continuous monitoring is important for debugging performance issues. You can use Ctrl+C to stop the continuous output.

By mastering the free command and its options, you gain a powerful tool for understanding and managing your Linux system’s memory resources. This is essential for optimizing performance and troubleshooting memory-related problems.