Skip to content

How to Check Disk Space in Linux (df and du Commands)

DodaTech 1 min read

In this tutorial, you'll learn about How to Check Disk Space in Linux (df and du Commands). We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

The Problem

Your server is running out of space. You need to find what's consuming disk and free it up.

Quick Fix

Check overall disk usage

df -h

Expected output:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       100G   75G   25G  75% /

The -h flag shows human-readable sizes (G, M, K).

Find the largest directories

du -sh /* 2>/dev/null | sort -rh | head -10

This shows the top 10 largest directories at the root level.

Find the largest directories in the current folder

du -sh * 2>/dev/null | sort -rh | head -10

Find files larger than 100MB

find / -type f -size +100M -exec ls -lh {} \; 2>/dev/null | sort -k5 -rh | head -20

Check a specific directory

du -sh /var/log

Useful Flags

Command What it does
df -h Human-readable disk free
df -i Check inode usage (many small files fill inodes)
du -sh * Total size of each item in current dir
du -h --max-depth=1 One level deep
du -h --time Show last modified time

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro