du

Estimate File and Directory Space Usage

What Does It Do?

The du command (disk usage) estimates and displays the disk space used by files and directories. Unlike df which shows filesystem-level space, du shows space used by specific directories and files.

Think of du as a detective that helps you find which folders are eating up your disk space. While df tells you "your disk is 90% full," du helps you answer "WHERE is all that space going?" IT administrators use du to track down space hogs before servers run out of room. Common culprits are log files growing out of control, forgotten database dumps, or users filling up their home directories. Use du -sh * to quickly see the size of everything in a directory, or du -h --max-depth=1 to limit how deep it searches. It's one of the first commands you run when someone says "the server is out of space!"

Advertisement

[ Insert Google AdSense Banner Code Here ]

When Should I Use It?

Find Space Hogs

Identify which directories are consuming the most disk space.

Clean Up Disk Space

Find large files and directories to delete or archive.

Analyze Log Growth

Check if log files are growing too large and need rotation.

Monitor User Directories

Track disk usage by individual users in /home directories.

Common Commands

du -sh /home/user

Show total size of user's home directory in human-readable format.

du -h --max-depth=1

Show size of subdirectories (1 level deep) in human-readable format.

du -h /home/user/Documents

Show detailed size breakdown of Documents folder and its subdirectories.

du -sh /var/log

Check total size of system logs (summary only).

du -h /home/user/Downloads

See which folders in Downloads are taking up space.

du -sh /home/user/Videos

Get total size of Videos folder (often the largest).

du -h

Show disk usage for current directory in human-readable format.

du -sh /var/cache

Check cache size (often safe to clean if disk is full).

IMPORTANT TIPS

Use -sh for quick checks: du -sh * is the fastest way to see what's using space in a directory.

Limit depth to save time: Use --max-depth=1 or -d 1 to avoid scanning too deep into nested folders.

Combine with sort: du -h | sort -h sorts by size to find the biggest space consumers (advanced usage).

Try It Yourself

Practice du commands in the interactive terminal below: