How to Check Disk Usage on Linux
Check filesystem usage, find large directories, and troubleshoot Linux storage problems step by step.
Before you start
Step-by-step instructions
1. Check overall filesystem usage first
Start with df -h. This shows which mounted filesystem is actually running out of space. Do not jump into random directories before confirming which filesystem is full.
df -h
Check the Use% column. If a filesystem is close to 100%, that is your first target. Also note the mount point because the full filesystem may not be the root filesystem.
2. Check the size of major directories
Once you know which filesystem is full, move into the relevant path and check large directories with du. This is how you narrow the problem from filesystem level to directory level.
du -sh /var/* 2>/dev/null
On many servers, heavy usage often comes from /var/log, /var/lib, backups, cache, or uploaded files. This quickly tells you which branch is worth drilling into.
3. Drill down into the heavy path
If one directory is clearly large, move one level deeper. Repeat this until you find the exact path responsible for the usage.
du -h --max-depth=1 /var 2>/dev/null | sort -h
This is usually more useful than checking everything recursively at once. You want to move from big picture to exact location without getting buried in noise.
4. Check common storage trouble spots
On real servers, the biggest space consumers are often logs, backups, cache, uploaded files, database storage, and mail queue data. Check the obvious operational paths before assuming something unusual is wrong.
du -sh /var/log 2>/dev/null
du -sh /var/lib 2>/dev/null
du -sh /home 2>/dev/null
du -sh /tmp 2>/dev/null
A log file grows unexpectedly, backups stack up, cache is not cleaned, or application uploads become larger than expected over time.
5. Confirm before cleanup or deletion
Once you find the heavy path, confirm what it contains and why it exists. Cleaning up safely is part of the diagnosis process. Do not remove files just because they look large.
ls -alh /var/log
A large file may be a live log, a database file, an application asset store, or an active queue. Confirm ownership and purpose before you clean anything.
Real example
A server shows / at 96% in df -h. You then run du -h --max-depth=1 /var and find that /var/log is unusually large. Drilling deeper shows that one application log has grown to several gigabytes because log rotation is missing or broken.
This is the kind of workflow you want: filesystem first, major directory second, exact path third, cleanup decision last.
Possible causes
- Large log files caused by missing or failed log rotation
- Backups accumulating in a local directory
- Application uploads or generated assets growing over time
- Cache or temporary files not being cleaned
- Database storage growth under
/var/lib - Mail queue or spool directories increasing unexpectedly
Common mistakes
- Running only
duwithout checkingdffirst - Checking the wrong mount point and missing the real full filesystem
- Deleting large files before confirming what they are used for
- Ignoring hidden operational paths like logs, cache, spool, or backup directories
- Assuming root filesystem usage and directory usage always match perfectly
Environment tips
- Use
df -hfor quick filesystem status anddufor path-level breakdown. - On busy production servers, redirect permission errors with
2>/dev/nullwhen scanning wide paths. - Check whether log rotation, backup retention, and cache cleanup are working as intended.
- If numbers do not make sense, verify mount points and consider whether deleted files are still being held open by processes.
About this guide
This guide shows how to check disk usage on Linux using practical commands such as df and du. It is designed for real server work, not just basic command reference. You will learn how to see overall filesystem usage, identify large directories, narrow down storage problems, and avoid common mistakes while checking disk space.
How to follow this guide
- Use df -h to check overall filesystem usage first.
- Use du -sh on important directories to see where space is being used.
- Drill down into large paths with du -sh * or du -h --max-depth=1.
- Check whether logs, uploads, backups, or cache directories are growing unexpectedly.
- Confirm the result before deleting anything important.
Why use this method?
Disk usage issues are one of the most common causes of server problems. Full filesystems can break uploads, stop services, prevent logs from being written, and cause database or mail delivery problems. A correct disk usage check helps you find the real storage bottleneck quickly instead of guessing.
Frequently Asked Questions
What is the difference between df and du?
df shows usage by filesystem, while du shows usage by directory or file path. In practice, df tells you which filesystem is full and du helps you find what inside that filesystem is using the space.
Why does df show high usage even when I cannot find large files easily?
This can happen when deleted files are still held open by a running process, when hidden paths are skipped, or when you are checking the wrong mount point. In that case you may need to inspect processes, mount points, and directory boundaries more carefully.
Is du -sh enough for troubleshooting?
It is a good start, but not always enough. Real troubleshooting often requires moving step by step from filesystem level to directory level and then into the specific heavy path.
Can I safely delete files right after checking disk usage?
Not always. You should confirm what the files are, whether services depend on them, and whether the path is part of logs, backups, cache, uploads, or application data before deleting anything.