TECHRUNBOOK · PRACTICAL GUIDE

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.

Linux Administration Troubleshooting
Practical Runbook Linux Disk Troubleshooting
Have a Linux disk-space problem? Post your issue to the TechRunbook Community and get help from other IT professionals.
Ask the Community →
! Issue

Linux systems can run out of disk space because of logs, application data, package caches, temporary files, backups or unexpectedly large directories.

Solution

Use df -h to identify full filesystems, then use du and find to locate the directories and files consuming the space.

Recommendation

Identify the cause before deleting anything. Review large files, logs and application data before making changes.

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

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 the human-readable option:

df -h

The -h option displays sizes in a more readable format such as GB and MB.

02

Understand df -h Output

df -h

A typical result contains columns such as:

  • Filesystem — the filesystem or device.
  • Size — total filesystem size.
  • Used — space currently used.
  • Avail — available space.
  • Use% — percentage of space used.
  • Mounted on — filesystem mount point.

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

03

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.

04

Check Disk Space in a Specific Directory 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.
05

Find Which Directories Are Using the Most Space

A useful first step is to inspect the 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 to make large directories easier to identify:

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

Find Large Files With find

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

For example, find files larger than 100 MB:

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

To find files larger than 1 GB:

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

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 slightly between Linux implementations, so verify the supported find options on your distribution with:

man find
08

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 on a Linux system.

09

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 at or 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.

When investigating this situation, check for open deleted files using tools available on your distribution, such as:

sudo lsof +L1

If lsof is installed, 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
sudo du -xh --max-depth=1 /var/log | sort -h

Then inspect particularly large 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 container storage can also consume significant disk space.

Inspect directories rather than deleting their contents blindly:

sudo du -xh --max-depth=1 /tmp | sort -h
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 Container Storage

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

If Docker is installed, inspect its disk usage:

docker system df

This provides an overview of Docker's storage consumption.

Do not blindly run 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

Check Disk Space With a Simple Workflow

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

  1. Run df -h to identify the full filesystem.
  2. Run df -i to check inode usage.
  3. Use du to identify large directories.
  4. Use find to locate unusually large files.
  5. Inspect logs, application data, caches and backups.
  6. Check for deleted files still held open by processes if df and du disagree.
  7. Make the smallest safe cleanup or configuration change.
  8. Run df -h again and validate the application.
15

Quick Disk-Space Troubleshooting Path

Disk-space issue

Step 1: Run df -h.

Filesystem full?
→ No: investigate application behavior, mounts and other possible causes.
→ Yes: continue.

Step 2: Run df -i.

Inodes full?
→ Yes: locate directories containing large numbers of files.
→ No: continue.

Step 3: Use du to identify large directories.

Step 4: Use find to locate large files.

Step 5: Review logs, application data, backups, caches and container storage.

Step 6: If df and du disagree significantly, investigate open deleted files.
16

df vs du vs lsblk vs find

Command Best used for Example
df Filesystem capacity and free space df -h
du Directory and file usage du -sh /var/log
lsblk Disks, partitions and block devices lsblk -f
find Finding files based on conditions find /var -type f -size +100M
17

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.

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 capacity while running out of inodes.

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.

Cleaning production systems without a plan

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

18

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
19

Frequently Asked Questions

How do I check disk space in Linux?

Use df -h to display 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?

You can use find. For example: find /var -type f -size +100M 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. Checking open deleted files can help identify this situation.

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.

References

Use official documentation when validating command syntax and distribution-specific behavior.

Was this guide helpful?
↑ Top