DEV Community

Cover image for How to Find Large Files and Directories in Linux
Meghna Meghwani for ServerAvatar

Posted on Originally published at serveravatar.com

How to Find Large Files and Directories in Linux

Disk space doesn’t vanish, it accumulates. One day your server is fine; the next, find large files and directories in Linux to uncover what filled your storage.

This is one of the most common scenarios I encounter in day-to-day server management. And on Linux, unlike desktop operating systems, there’s no friendly animation telling you where space went. You have to find it yourself.

The good news: Linux ships with powerful built-in tools for exactly this. And there are lightweight third-party utilities that make the process much less painful. I’ve used these tools across dozens of servers, development boxes, production VPS instances, and everything in between. Some of them have saved me hours of detective work.

This guide walks you through how to find large files and directories in Linux, from quick one-liners to interactive analyzers, and explains the nuances that documentation rarely covers.

disk usage warning - find large files and directories in Linux

Why Disk Space Management Matters on Linux

Running out of disk space can affect much more than file storage. A nearly full filesystem can prevent applications from writing data, break database operations, interrupt deployments, and cause system services to fail.

Common sources of unexpected disk usage include:

  • Log files that continuously grow because of application errors or verbose logging.

Learn more about Linux logging, common log locations, and how log files are used in our guide to Linux logs.

  • Database backups and snapshots that are never removed.

  • Compressed backup archives such as .rar, .zip, and .tar files can also consume significant storage when old copies are retained.

If you need to work with RAR archives on Linux, see our guide on How to Open, Extract and Create RAR Files in Linux.

  • Container images and volumes left behind after testing.

  • CI/CD build artifacts that accumulate over time.

  • Package caches containing outdated packages.

  • Temporary files created by applications and system processes.

  • Old application releases that are no longer required.

  • Backup jobs writing files to an unexpected location.

Why regular disk checks are important

A simple disk-space monitoring routine can help you:

  • Detect storage problems before they become critical.
  • Identify which filesystem is filling up.
  • Find unusually large directories and files.
  • Discover deleted files that are still consuming space.
  • Prevent applications from failing because of insufficient storage.
  • Keep production servers healthy and predictable.

Tip: Don’t wait until a filesystem reaches 100%. Investigate sustained usage above 80% and treat 90%+ as a warning that requires attention.

Check Overall Disk Usage First

Before searching for individual files, determine which filesystem is consuming the most space.

The df command provides a summary of disk usage for mounted filesystems.

df -h
Enter fullscreen mode Exit fullscreen mode

The -h flag gives you human-readable output, gigabytes and megabytes instead of raw block counts.

check disk usage to find large files and directories in Linux

You can also review the official GNU ‘df’ documentation for additional options such as -i, -T, and -x.

Here’s what the output typically looks like:

Filesystem     Size   Used   Avail   Use%   Mounted on
/dev/sda1      100G    78G     22G    78%   /
/dev/sdb1      500G   450G     50G    90%   /mnt/backup
tmpfs          2.0G      0    2.0G     0%   /tmp
Enter fullscreen mode Exit fullscreen mode

Pay particular attention to:

  • Size: Total filesystem capacity.
  • Used: Space currently occupied.
  • Avail: Remaining available space.
  • Use%: Percentage of the filesystem in use.
  • Mounted on: Location where the filesystem is accessible.

In the example above, /mnt/backup is at 90%, making it the first location to investigate.

For more details about df, du, and other filesystem utilities, see the GNU Coreutils documentation.

Check inode usage

Disk space isn’t the only resource that can run out. Linux filesystems also have a finite number of inodes, which store metadata about files.

Check inode consumption with:

df -i
Enter fullscreen mode Exit fullscreen mode

Here’s what the output typically looks like:

check linode usage for find large files and directories in Linux

Inode exhaustion can occur when a server contains millions of small files, even when plenty of disk capacity remains.

For example:

  • A server may have 100 GB of free disk space.
  • But all available inodes may already be consumed.
  • Creating a new file can then fail despite the available storage.

For a deeper explanation of what an inode stores, see the Linux ‘inode(7)’ manual page.

Read Full Article: https://serveravatar.com/find-large-files-directories-linux

Top comments (0)