Chapter 31: Bash Memory Usage (free)

What does free actually do? (super simple first)

free = shows you memory usage statistics (RAM + swap) in a very quick, readable way.

It tells you:

  • How much total RAM your computer has
  • How much is used, free, shared, in buffers/cache, and available
  • How much swap (virtual memory on disk) is used

This is one of the first commands almost every Linux user runs when the system feels slow, when a program crashes with “out of memory”, or when they want to check if they need more RAM.

1. Basic usage (try right now!)

Just type:

Bash

You will see something like this (example from a typical 16 GB laptop in 2026):

text

Numbers are in KiB (kibibytes = 1024 bytes) by default → hard to read.

2. The MOST important way – human readable (always use this!)

Bash

Now it shows in GB / MB – much easier:

text

3. Understand every column (very important – many people get confused here!)

Column What it really means Example value When to worry
total Total physical RAM installed 15Gi
used RAM actively used by processes (but not including cache) 8.0Gi High is normal if available is good
free Completely unused RAM (almost never high on healthy system) 1.2Gi Low free is normal & good
shared Memory used by tmpfs (RAM disks) + memory shared between processes 570Mi Usually small
buff/cache RAM used for disk cache + buffers (very good – Linux uses free RAM for speed) 6.3Gi High is excellent
available The most important number! → How much RAM programs can still use right now 6.8Gi <1–2 GiB → may start swapping
Swap total/used/free Swap space on disk (virtual memory) 2.0Gi / 0B / 2.0Gi Swap used > 0 → performance drop

Golden rule everyone should remember (2026 style):

  • free column being low → completely normal and healthy
  • Linux loves using “free” RAM for buff/cache to make disk reads super fast
  • The only number you should really care about is available → if available drops below ~10–15% of total RAM for long time → system will start using swap → becomes slow

4. Very useful options (you’ll use these often)

Bash

5. Real-life examples you will use daily

  • Laptop feeling slow after opening 20 Chrome tabs?
    Bash
  • Checking before running heavy ML training (PyTorch / TensorFlow)
    Bash
  • Server saying “out of memory” errors?
    Bash
  • Is swap being used? (bad for performance)
    Bash
  • Quick check in script (example: alert if available < 2GB)
    Bash

6. Quick cheat-sheet table

Goal Command example What to look at
Quick readable view free -h available column
With total line free -h –total Total RAM + used
Live monitoring watch -n 2 free -h Watch available drop
Only memory line free -h grep Mem
In megabytes free -m Scripts / old eyes
Wide view (shows cached separately) free -wh Compare old vs new style
Check if swap is used free -h grep Swap

7. Pro tips & common misunderstandings (very important!)

  • Myth: “My free RAM is only 1 GB – bad!” → No! Low free is good if available is high – Linux is using it for cache.
  • Most important number = available (It already subtracts what kernel thinks you can’t safely use)
  • Swap used a lot → system will feel very slow (especially on HDD) → Solution: close heavy apps, add RAM, or lower vm.swappiness (default 60)
  • Modern systems (16–32 GB) often show 0B swap used – that’s ideal

Now open your terminal and try these 3 right now:

Bash
  • How much available RAM do you have right now? (e.g. 6.8Gi)
  • Is your swap used 0B or some value?

Or ask:

  • “What to do if available is always below 2 GB?”
  • “free vs htop vs top – which shows memory best?”
  • “How to reduce swap usage?”

We’ll go deeper together! 😄

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *