Skip to main content

How to Check Disk Space and Usage in Linux Using df and du

Learn how to efficiently monitor disk storage and analyze file system usage on Linux machines using essential commands like df, du, and find.

AI-written
Inewgen
30 Oct 2026Source: Dev.to4 min read (0 views)
Share
How to Check Disk Space and Usage in Linux Using df and du

Stock photo for illustration only, not from the actual event

Font size
  • A full disk can degrade system performance and cause service failures
  • The df command provides a quick overview of system-wide disk usage
  • The du command helps analyze specific file and directory sizes
  • Combining commands enables fast tracking of large files on Linux

A full storage disk can severely degrade Linux system performance, trigger service failures, and even block users from logging in or reaching vital directories. Keeping a close eye on disk consumption remains a fundamental task for maintaining any Linux environment. Linux comes equipped with built-in command-line utilities—specifically df, du, and find—that allow administrators to inspect utilized storage, available capacity, and pinpoint precisely which files or directories are consuming valuable disk space.

This guide explores practical examples of each utility, enabling you to check available disk space, analyze mounted file systems, and troubleshoot storage-related bottlenecks efficiently. By the end, you will possess a reliable toolkit of commands to monitor disk consumption and track down oversized files across any Linux distribution.

Linux features several essential command-line tools designed to monitor and manage disk storage effectively. The df utility offers an immediate overview of disk usage across all active mounted file systems, allowing you to identify partitions running low on free space and take action before performance drops. The standard syntax is df [OPTION]... [FILE]..., and omitting a file or directory displays space for all mounted file systems.

linux command line interface monitor code

Stock photo for illustration only, not from the actual event

Key use cases and examples for the df command include:

Never miss the latest news?

Subscribe to get news summaries by email - not often enough to be annoying.

โฆษณา

  • Display human-readable usage: Use df -h to output capacities in easily digestible formats.
  • Check a specific mount point: Run df -h /mnt to inspect an individual partition.
  • Filter by file system type: Use df -h -t ext4 to target specific file systems like ext4.
  • Exclude specific file systems: Run df -h -x tmpfs to omit temporary systems from results.
  • Include file system types: Use df -hT to display the type column alongside capacity metrics.
  • Monitor inode usage: Execute df -i to track total, used, and free inodes for managing file counts.

Understanding the distinction between raw disk space and inode availability is critical. Systems can sometimes report ample free disk space while rejecting new file creation simply because the inode table is exhausted—often caused by massive quantities of tiny files. Running df -i helps catch this overlooked bottleneck early.

Meanwhile, the du (disk usage) utility estimates and displays storage consumed by specific files and directories, assisting administrators in locating bulky folders that require cleaning. Its basic syntax is du [OPTION]... [FILE]..., defaulting to the current working directory if no path is supplied.

Important examples of the du command include:

  • Check directory size cleanly: Run sudo du -sh /path/to/directory, typically requiring elevated privileges due to restricted folder permissions.
  • Include hidden files: Append the -a flag to track dotfiles and hidden configurations.
  • Exclude temporary logs: Use sudo du -ah --exclude='*.log' /path/to/directory to ignore irrelevant log files.
  • Limit directory depth: Run sudo du -h --max-depth=1 /var to inspect top-level subdirectories.
  • Sort by largest size: Pipe the output through | sort -rh to list the biggest directories at the top.

Additionally, you can combine find and du operations to locate massive files—such as assets exceeding 50MB inside /var—revealing exact file sizes, permission structures, and recent modification dates.

Source: Dev.to

Comments

Leave a Comment
0/2000

Found something wrong in this article? Report an issue with this article