Linux

How to Check Disk Space in Linux

See how much disk space is free on a Linux server and find the folders using the most space, with two beginner-friendly commands: df and du.

A full disk can stop websites, email and databases from working. These two commands tell you how much space is left and what is using it. They only read information, so they are safe to run.

Check free space with df

df -h

-h shows sizes in GB and MB instead of bytes. Look at the line where Mounted on is /. That is your main disk. If Use% is above 90%, it is time to clean up. GNU Coreutils manual

Find what is using the space with du

du -h --max-depth=1 / 2>/dev/null | sort -h

This lists each top-level folder with its size, biggest last. Repeat it on the largest folder, for example /var, to dig deeper.

What to do next

  • Old log files in /var/log are a common cause.
  • Old backups in /home or /backup are another.
  • Do not delete files you do not recognise. Check what they are first.

Sources

  1. GNU Coreutils manual: df and du

Written by Tharanga. Commands and procedures depend on your system and software version.

How we approach technical guides →
FOLLOW THE THREAD

Keep exploring

All guides