Skip to content
-
Check latest Techrunbook articles. Click here!
TechRunbook
TechRunbook
  • Home
  • About Us
  • Contact
  • Terms of Use
  • Home
  • About Us
  • Contact
  • Terms of Use
Close

Search

Linux File Permissions
Linux

How to Check Disk Space in Linux: df, du, and Troubleshooting

By Bilal Khan
September 17, 2026 8 Min Read
0

How to Check Disk Space in Linux

Learn how to check available and used disk space in Linux using df, du, lsblk, and find, then troubleshoot what is consuming storage when a filesystem becomes full.

Written by Bilal Khan · Updated: 2026-09-17

Table of Contents

  • How to Check Disk Space in Linux
  • Why Check Disk Space in Linux?
  • 1. Check Disk Space With df
  • 2. Understand df -h Output
  • 3. Check a Specific Filesystem
  • 4. Check Directory Usage With du
  • 5. Find Which Directories Are Using the Most Space
  • 6. Find Large Files With find
  • 7. Find the Largest Files and Sort Them
  • 8. Check Disk Devices With lsblk
  • 9. Check Inodes When Disk Space Looks Normal
  • 10. Why df and du Can Show Different Results
  • 11. Check Log Files
  • 12. Check Temporary and Application Data
  • 13. Check Docker Storage
  • 14. Linux Disk-Space Troubleshooting Workflow
    • Step 1 — Identify the full filesystem
    • Step 2 — Check inode usage
    • Step 3 — Identify large directories
    • Step 4 — Find large files
    • Step 5 — Investigate the cause
    • Step 6 — Check for deleted files
    • Step 7 — Make a controlled change
    • Step 8 — Validate
  • Deleting files without identifying the cause
  • Using rm on system directories
  • Ignoring inode usage
  • Ignoring open deleted files
  • Cleaning production systems without a plan
  • How do I check disk space in Linux?
  • What is the difference between df and du in Linux?
  • How do I find large files in Linux?
  • Why does Linux say the disk is full when df and du show different results?
  • How can I check inode usage in Linux?
  • Is it safe to delete large Linux log files?
  • Related TechRunbook Guides
  • References

TechRunbook approach: First determine which filesystem is full, then determine which directory or file is responsible. This prevents guesswork and unnecessary deletion.


Why Check Disk Space in Linux?

Linux systems can run out of disk space because of:

  • Large log files
  • Application data
  • Package caches
  • Temporary files
  • Backups
  • Docker images and containers
  • Large numbers of small files
  • Deleted files still held open by running processes

The first step is to determine how much space is available and which filesystem is affected.


1. Check Disk Space With df

The df command reports the amount of disk space used and available on mounted filesystems.

df

For most troubleshooting tasks, use:

df -h

The -h option displays sizes in a human-readable format.


2. Understand df -h Output

Run:

df -h

Typical output contains columns such as:

ColumnMeaning
FilesystemFilesystem or device
SizeTotal filesystem size
UsedSpace currently used
AvailAvailable space
Use%Percentage of space used
Mounted onFilesystem mount point

The most important column during a disk-space incident is usually Use%.

For example:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        80G   72G  8.0G  90% /

3. Check a Specific Filesystem

You can check the filesystem containing a particular path:

df -h /var

This is useful when an application reports that a directory such as /var is running out of space.


4. Check Directory Usage With du

While df tells you about filesystem capacity, du helps identify how much space files and directories are using.

Check the size of a directory:

du -sh /var/log

The options mean:

  • -s — show a summary
  • -h — use human-readable sizes

Example:

2.4G    /var/log

5. Find Which Directories Are Using the Most Space

A useful first step is to inspect major directories under a filesystem.

sudo du -xh --max-depth=1 /

For a particular directory:

sudo du -xh --max-depth=1 /var

Sort the results:

sudo du -xh --max-depth=1 /var | sort -h

This makes larger directories easier to identify.


6. Find Large Files With find

Once you identify a directory consuming significant space, use find to locate large files.

Find files larger than 100 MB:

sudo find /var -type f -size +100M -print

Find files larger than 1 GB:

sudo find /var -type f -size +1G -print

You can change the size threshold depending on the system you’re investigating.


7. Find the Largest Files and Sort Them

You can combine find with other Linux commands to identify large files.

sudo find /var -type f -printf '%s %p\n' 2>/dev/null | sort -nr | head -20

This approach lists the largest files first.

Command behavior can vary between Linux implementations, so check the supported options on your distribution:

man find

8. Check Disk Devices With lsblk

The lsblk command displays block devices and their relationships.

lsblk

For filesystem information:

lsblk -f

This is useful when you need to understand which disks, partitions, and filesystems are present.

Example:

NAME   FSTYPE FSVER LABEL UUID                                 MOUNTPOINT
sda
├─sda1 ext4         root  1234-5678                            /
└─sda2 ext4         data  9876-5432                            /data

9. Check Inodes When Disk Space Looks Normal

A filesystem can have available storage but still fail to create new files if it has exhausted its available inodes.

Check inode usage with:

df -i

If inode usage is near 100%, look for directories containing very large numbers of small files.

Important: If df -h shows plenty of free space but applications cannot create files, checking df -i can help identify an inode-related problem.


10. Why df and du Can Show Different Results

It is possible for df and du to report different amounts of used space.

One common reason is that a process can keep an already deleted file open.

The directory entry is removed, but the filesystem space can remain allocated until the process releases the file.

If lsof is installed, check for open deleted files:

sudo lsof +L1

This can help identify processes holding deleted files open.


11. Check Log Files

Logs are a common source of unexpected disk consumption on servers.

Start by checking the size of common log locations:

sudo du -sh /var/log

Then inspect individual directories:

sudo du -xh --max-depth=1 /var/log | sort -h

Find particularly large log files:

sudo find /var/log -type f -size +100M -ls

Before deleting logs, determine whether log rotation or the application generating the logs needs attention.


12. Check Temporary and Application Data

Temporary files, application caches, package data, and other application files can consume significant disk space.

Inspect directories rather than deleting their contents blindly:

sudo du -xh --max-depth=1 /tmp | sort -h

You can also inspect /var:

sudo du -xh --max-depth=1 /var | sort -h

The exact directories worth investigating depend on the software and Linux distribution installed on the system.


13. Check Docker Storage

On systems running Docker, images, containers, volumes, and build cache can consume significant disk space.

Check Docker’s disk usage:

docker system df

This provides an overview of Docker storage consumption.

Warning: Do not blindly run Docker cleanup commands. Review unused images, containers, networks, and volumes before removing them. A resource that appears unused may still be needed by an application or deployment workflow.


14. Linux Disk-Space Troubleshooting Workflow

When a Linux server reports low disk space, use a structured workflow instead of immediately deleting files.

Step 1 — Identify the full filesystem

df -h

Look for filesystems approaching or reaching 100% usage.

Step 2 — Check inode usage

df -i

If inode usage is high, investigate directories containing large numbers of files.

Step 3 — Identify large directories

sudo du -xh --max-depth=1 / | sort -h

Then investigate the largest directory.

Step 4 — Find large files

sudo find /var -type f -size +100M -print

Replace /var with the directory you identified.

Step 5 — Investigate the cause

Check:

  • Logs
  • Application data
  • Backups
  • Package caches
  • Temporary files
  • Docker storage
  • Large user files

Step 6 — Check for deleted files

If df and du don’t appear to agree:

sudo lsof +L1

Step 7 — Make a controlled change

Don’t delete files simply because they are large.

First determine whether they are required by the operating system, an application, a backup process, or a logging system.

Step 8 — Validate

Run:

df -h

again and confirm that the original application or system problem has been resolved.


Quick Disk-Space Troubleshooting Path

                 Disk-space issue
                         |
                         v
                    df -h
                         |
              +----------+----------+
              |                     |
          Filesystem             Normal
             full?                  |
              |                     |
          Yes |                     v
              |              Investigate other
              v                possible causes
            df -i
              |
       +------+------+
       |             |
  Inodes full?      No
       |             |
      Yes            v
       |       Use du to locate
       v       large directories
Find directories          |
with many files           v
                    Use find to
                    locate files
                         |
                         v
                 Review logs,
               application data,
              backups and caches
                         |
                         v
                 Controlled cleanup
                         |
                         v
                      df -h
                         |
                         v
                     Validate

df vs du vs lsblk vs find

CommandBest used forExample
dfFilesystem capacity and free spacedf -h
duDirectory and file usagedu -sh /var/log
lsblkDisks, partitions and block deviceslsblk -f
findFinding files based on conditionsfind /var -type f -size +100M

A simple way to remember them:

df = filesystem space

du = directory/file usage

lsblk = disks and partitions

find = locate files


Common Linux Disk-Space Mistakes

Deleting files without identifying the cause

Removing a large file may temporarily create free space without fixing the process that caused the growth.

Find the cause first.

Using rm on system directories

Never delete system files simply because they appear large.

Determine what they are and whether the associated service needs them.

Ignoring inode usage

A filesystem can have free storage while running out of inodes.

Use:

df -i

when appropriate.

Ignoring open deleted files

Deleting a log file doesn’t necessarily immediately return all its storage if a running process still has the file open.

Check:

sudo lsof +L1

Cleaning production systems without a plan

Disk cleanup should be controlled, documented, and validated, especially on production servers.


Linux Disk-Space Command Cheat Sheet

# Show filesystem usage
df -h

# Show inode usage
df -i

# Show filesystem containing a path
df -h /var

# Show directory size
du -sh /var/log

# Show immediate subdirectory sizes
du -xh --max-depth=1 /var | sort -h

# Find files larger than 100 MB
find /var -type f -size +100M -print

# Show disks and filesystems
lsblk -f

# Find deleted files still held open
sudo lsof +L1

# Check Docker disk usage
docker system df

How to Prevent Linux Disk-Space Problems

Troubleshooting is useful, but prevention is even better.

Consider implementing:

  • Log rotation
  • Monitoring and alerting
  • Disk-usage thresholds
  • Application data retention policies
  • Backup retention policies
  • Regular filesystem reviews
  • Docker image and volume management
  • Capacity planning

For production systems, consider alerting before a filesystem reaches a critical threshold rather than waiting for applications to fail.


Frequently Asked Questions

How do I check disk space in Linux?

Use:

df -h

This displays filesystem disk usage in a human-readable format.

What is the difference between df and du in Linux?

df reports filesystem capacity and available space, while du reports space consumed by files and directories.

How do I find large files in Linux?

Use find. For example:

find /var -type f -size +100M

This searches for files larger than 100 MB under /var.

Why does Linux say the disk is full when df and du show different results?

One possible cause is a deleted file that remains open by a running process.

If available, use:

sudo lsof +L1

to investigate.

How can I check inode usage in Linux?

Run:

df -i

It displays inode usage for mounted filesystems.

Is it safe to delete large Linux log files?

Not automatically.

First determine why the log is large and check the application’s logging and rotation configuration. Removing files without understanding their purpose can cause service or troubleshooting problems.


Final Thoughts

Checking disk space in Linux is more than running a single command.

A reliable troubleshooting process is:

df -h
   ↓
Identify the full filesystem
   ↓
df -i
   ↓
Check inode usage
   ↓
du
   ↓
Find large directories
   ↓
find
   ↓
Find large files
   ↓
Investigate the cause
   ↓
Make a controlled change
   ↓
Validate with df -h

The combination of df, du, find, lsblk, and lsof gives you a practical toolkit for investigating many Linux storage problems.

Once you’re comfortable with these commands, you’ll be better prepared for Linux administration, cloud servers, DevOps, Docker environments, and production troubleshooting.


Related TechRunbook Guides

  • 50 Essential Linux Commands for Beginners
  • How to Find Large Files in Linux
  • Linux File Permissions Explained
  • How to Kill a Process in Linux
  • Linux Networking Commands
  • Docker Tutorial for Beginners

References

  • Linux man-pages — df
  • Linux man-pages — du
  • Linux man-pages — find
  • Linux man-pages — lsblk
  • Linux man-pages — lsof

Check the latest blogs

Author

Bilal Khan

Follow Me
Other Articles
Linux commands
Previous

50 Essential Linux Commands for Beginners: With Examples

GPT-6 Astra
Next

GPT-6 Astra: What IT, Cloud, and Security Teams Need to Know Right Now

No Comment! Be the first one.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright 2026 — TechRunbook. All rights reserved.