How to Check Disk Space Linux Using du and df

Disk space Linux problems creep in silence. Growing log files and forgotten backups and cached packages are the main causes. And so is that one developer who “just needed temporary storage.” Then the bad moment hits. Your system refuses to update. Services crash. The dreaded message appears: no space left on device.

Panic is natural right then. But panic is unnecessary. Linux provides two friendly built-in tools that provide you visibility into storage usage: df and du. These commands are simple, fast, and practical.

To understand how to check disk usage is not bound to system administrators. Developers and DevOps engineers and even hobbyists who run VPS environments should master these commands. Disk space management is about smart filesystems and consistent checks.

Understanding Disk Space Linux Fundamentals

Disk usage in Linux is calculated at the filesystem level. Every mounted partition — root (/), home (/home), or var (/var) — has a defined capacity and usage percentage. Your system’s behaviour becomes unpredictable when that limit is reached.

There are two central questions you should always ask when monitoring storage. How much total space is being used on each filesystem? Which files or directories are consuming that space? Two layers. One offers you the overview. The other provides you the breakdown.

The df and du take part in the process and complement each other. 

df answers the first.
du answers the second.

df is like the top view of your storage landscape.
du is like a light inside your directories.

Disk Space Management Commands in Linux

Effective disk space management in Linux requires clarity and attention. Have a look at essential Linux storage commands.

The Role of the df Command

The df command is known as the filesystem reporter. The df command stands for disk filesystem. Goes to show how much space each mounted filesystem is using. 

Most administrators prefer df -h because the -h flag enables human readability. You see clean values like 10G instead of raw block counts such as 10485760. That makes interpretation easier. The output columns include:

Filesystem. Shows the device or mount point. 

Size. Displays total capacity. 

Used. Informs about consumed space. 

Avail. Shows remaining space. 

Use%. Tells about the percentage of space in use. 

Mounted on. Shares where the filesystem is attached in the system. 

You can run df -h /home to see how much space remains there if you want to check a specific filesystem such as /home.

Checking Available Space through the df Command

The first command to run is df -h when a system becomes slow or refuses to write files. 

Focus on the Use% column to understand system health. 

A value between 50 and 70 percent indicates normal conditions. 

Between 80 and 90 percent signals that monitoring is required. 

A value between 95 and 100 percent indicates a critical state. The server can turn unstable if the root filesystem reaches 100 percent.

Services may crash in that case. Updates can fail. Logs may stop writing because even error messages require disk space. It is also important to check inode usage with df -i. A system runs out of inodes in some cases before it runs out of disk space. A large number of small files can exhaust inode availability and cause filesystem issues.

The Importance of the du Command

The du command acts as the storage detective for deeper filesystem monitoring. df provides a broad view of usage across filesystems. du identifies which directories consume space. The basic usage du -h lists the size of the current directory and all subdirectories. 

A better approach is du -sh *.

-h enables human-readable values. 

The asterisk targets all items in the current directory. 

This allows you to see which directory consumes the most space. Output may show 4.0K for config and 2.1G for logs and 512M for backups. That makes the source of the issue clear.

Storage Investigation through du Command

Move step by step when you track storage problems. Start at the root directory with du -sh /* and identify large directories. Then drill down into candidates such as du -sh /var/* and continue until you locate the source of high usage. This method isolates the problem in a structured way.

Use du -sh * to sort directory sizes. 

Sort -h so that smaller directories appear first and larger ones appear last. 

Use du -ah | sort -h | tail -20 for a deeper scan of large files and directories. 

This displays the twenty largest files and directories in the current path and helps pinpoint space consumption with precision.

A Practical Workflow for Disk Space Monitoring

A structured approach works best when you diagnose disk issues. Start with df -h to identify which filesystem nears capacity. Move into that directory and use du -sh * to locate heavy subdirectories once that is identified. Continue the route until you isolate the exact files responsible.

This layered method prevents blind deletion and reduces risk. It also builds discipline. Effective disk space management is about understanding usage patterns.

Regular monitoring is as crucial. Automating checks through scheduled tasks ensures that storage problems are detected soon. Log rotation policies should be enforced. Temporary directories must be cleaned from time to time. Unused backups are to be archived or removed.

Common Mistakes to Avoid During Disk Space Management

Even experienced users slip up. Avoid these:

  1. Running du on/without limits.
  2. Ignoring inode usage.
  3. Deleting files without any verification.
  4. Forgetting about log rotation.
  5. Assuming bigger disks solves bad habits.

Storage problems are more about discipline than capacity.

Conclusion

Checking disk space Linux through df and du gives you clarity instead of chaos. These commands help you check available space and locate heavy directories as well as prevent silent storage failures. Consistent filesystem monitoring and disciplined cleanup habits keep your servers stable and predictable. Reach out to Ultahost for peak performance and smarter infrastructure management.

Frequently Asked Questions

What is the difference between df and du?
Why does df show more space used than du?
How do I check available disk space?
What are inodes and why should I monitor them?
How often should I check disk usage on Linux?

Related Post

Unlocking the power of Linux Pipe Command

The pipe command symbolized as the bar (“|”) enable...

How to Fix Update and Upgrade Issues in Kali ...

Kali Linux is a powerful and versatile operating system...

How to Create a Bash Script: Step-by-Step Gui...

Bash scripts are powerful tools that allow you to autom...

Exploring Sed Command in Linux

The sed command stands for stream editor is a powerful ...

How to Check Apache Version in Linux

Apache is a widely used, open-source web server compati...

Nohup Command in Linux

The Nohup command, which stands for "no hang up," is a ...

Leave a Comment