Chapter 29: Bash Disk Space (df)

What does df actually do? (super simple first)

df = disk free It shows you how much disk space is used and how much is still free on your mounted filesystems (hard drives, SSDs, USBs, network drives, etc.).

In simple words:

  • Tells you which partition/drive is almost full
  • Shows total size, used space, available space, % used
  • Very fast – doesn’t scan files, just asks the filesystem

Without df, you might suddenly get “No space left on device” error and not know which folder/drive is the culprit.

1. Basic usage (try right now!)

Just type:

Bash

You will see something like this (example from a typical laptop):

text

2. Make it human-readable (most important flag – always use this!)

Bash

Now it shows sizes in GB, MB, TB instead of 1K-blocks:

text

Much easier to understand!

3. Very common options (you’ll use these 90% of time)

Option What it does Example command Why useful?
-h Human-readable (GB, MB, TB) df -h Always use this!
-T Show filesystem type (ext4, ntfs, vfat…) df -hT Know if ext4, btrfs, etc.
–total Add grand total line at bottom df -h –total Quick total disk space
-i Show inode usage (not just bytes) df -hi When “no space” but df shows free space
–output=… Choose which columns to show df -h –output=source,size,used,avail,pcent,target Clean reports
-t / -x Include/exclude filesystem types df -h -t ext4 -t btrfs Only real disks

4. Real examples you should try right now

Bash

5. Understanding the columns (very important!)

Column Meaning Example value When to worry
Filesystem Device name or mount point /dev/sda5
Size Total capacity 224G
Used Space already used 140G High = danger
Avail Space still free 74G <10–15% → alert
Use% Percentage used 66% >90% = critical
Mounted on Where it’s attached in directory tree /

Rule of thumb (from sysadmins):

  • < 80% used → comfortable
  • 80–90% → start cleaning / watching
  • 90% → urgent – delete logs, old downloads, temp files

  • 100% → system may become unstable (especially /)

6. Real-life examples (Hyderabad style)

  • Laptop saying “disk full” when downloading movie?
    Bash
  • Server slow after many Docker containers?
    Bash
  • Check before big backup
    Bash
  • See total disk space across all drives
    Bash

7. Quick cheat-sheet table

Goal Command example Notes
Quick look (human readable) df -h Everyday use
Only root partition df -h / Most critical
Show filesystem types df -hT ext4 vs ntfs
Add total line df -h –total Grand total
Sort by % used descending df -h sort -k 5 -nr
Only real disks df -h -x tmpfs -x devtmpfs Ignore RAM disks
Inode usage (many small files) df -hi “No space” but space free?
Clean columns only df -h –output=source,size,used,avail,use%,target Reports

8. Pro tips from daily use

  • Always use -h – numbers without it are confusing (1K-blocks)
  • When “No space left” but df shows free space → check inodes with -i
  • df only shows mounted filesystems – unmounted drives won’t appear
  • For more detail (which folder eating space) → use du, not df
    Bash

Now open your terminal and try these 3 right now:

Bash

Tell me:

  • How much % is your root (/) using right now?
  • Or ask: “What to do if / is 95% full?” or “df vs du – difference?” or “How to check external USB drive?”

We’ll solve it together! 😄

You may also like...

Leave a Reply

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