Find Large Files in Linux: Using find and du

By 

Updated on

6 min read

Terminal showing large files found with the find command in Linux

Over time, your disk drive may get cluttered with a lot of unnecessary files taking up large amounts of disk space. Usually, Linux systems run out of disk space due to large log or backup files.

This tutorial explains how to find the largest files and directories in Linux systems using the find and du commands.

Quick Reference

CommandDescription
find / -xdev -type f -size +100MFind files larger than 100 MB
find / -xdev -type f -size +1GFind files larger than 1 GB
find . -type f -size +50M -exec ls -lh {} +List large files with details
du -ahx . | sort -rh | head -10Top 10 largest files and directories
du -hsx * | sort -rh | head -10Top 10 largest items in current directory
sudo updatedb && locate -i '*.log'Find log files by name

For a printable quick reference, see the Find cheatsheet .

Find Large Files Using the find Command

The find command is one of the most powerful tools in the Linux system administrator’s toolkit. It allows you to search for files and directories based on different criteria, including the file size.

For example, to search for files larger than 100 MB in the current working directory , you would run the following command:

Terminal
sudo find . -xdev -type f -size +100M
Info
Replace . with the path to the directory where you want to search for the largest files.

The output will show a list of files without any additional information:

output
/var/lib/libvirt/images/centos-7-desktop_default.img
/var/lib/libvirt/images/bionic64_default.img
/var/lib/libvirt/images/win10.qcow2
/var/lib/libvirt/images/debian-9_default.img
/var/lib/libvirt/images/ubuntu-18-04-desktop_default.img
/var/lib/libvirt/images/centos-7_default.img

The -size option accepts the following suffixes:

  • k — Kilobytes
  • M — Megabytes
  • G — Gigabytes

Use + for “greater than” and - for “less than”. For example, -size +1G finds files larger than 1 GB.

Sorting Large Files by Size

The find command can also be used in combination with other tools such as ls or sort to display detailed information about the found files.

In the following example, we are using -exec to run ls -lh on each found file and then piping the output to sort to sort it based on the 5th column, which is the file size:

Terminal
find . -xdev -type f -size +100M -exec ls -lh {} + | sort -k5,5 -h -r

The output will look something like this:

output
-rw-------  1 root   root 40967M Jan  5 14:12 /var/lib/libvirt/images/win10.qcow2
-rw-------  1 root   root  3725M Jan  7 22:12 /var/lib/libvirt/images/debian-9_default.img
-rw-------  1 root   root  1524M Dec 30 07:46 /var/lib/libvirt/images/centos-7-desktop_default.img
-rw-------  1 root   root   999M Jan  5 14:43 /var/lib/libvirt/images/ubuntu-18-04-desktop_default.img
-rw-------  1 root   root   562M Dec 31 07:38 /var/lib/libvirt/images/centos-7_default.img
-rw-------  1 root   root   378M Jan  7 22:26 /var/lib/libvirt/images/bionic64_default.img

If the output contains a lot of lines, you can use the head command to print only the first 10 lines:

Terminal
find . -xdev -type f -size +100M -exec ls -lh {} + | sort -k5,5 -h -r | head

Let us break down the command:

  • find . -xdev -type f -size +100M — Search only for files (-type f) in the current working directory (.), larger than 100 MB (-size +100M), and do not descend directories on other filesystems (-xdev).
  • -exec ls -lh {} + — Run ls -lh on the found files. The {} is replaced with the file name, and + passes multiple files to a single ls invocation.
  • sort -k5,5 -h -r — Sort lines based on the 5th column (-k5,5), compare the values in human-readable format (-h), and reverse the result (-r).
  • head — Print only the first 10 lines of the piped output.

The find command comes with a lot of powerful options. For example, you can search for large files that are older than x days, large files with a specific extension, or large files that belong to a particular user.

Find Large Files and Directories Using the du Command

The du command is used to estimate file space usage, and it is particularly useful for finding directories and files that consume large amounts of disk space.

The following command will print the largest files and directories:

Terminal
du -ahx . | sort -rh | head -5

The first column includes the size, and the second is the file name:

output
55G	.
24G	./.vagrant.d/boxes
24G	./.vagrant.d
13G	./Projects
5.2G	./.minikube

Here is what each part does:

  • du -ahx .Estimate disk space usage in the current working directory (.), count both files and directories (-a), print sizes in a human-readable format (-h), and skip directories on different file systems (-x).
  • sort -rh — Sort lines by comparing values in human-readable format (-h) and reverse the result (-r).
  • head -5 — Print only the first five lines of the piped output.

The du command has many other options that can be used to refine the output of the disk space usage.

Troubleshooting

find returns many Permission denied messages
Run the command with sudo when appropriate, or silence permission errors with 2>/dev/null if you only need the result list.

Results include files from mounted drives you do not want to scan
Use -xdev to stay on the current filesystem and avoid traversing other mount points.

The scan is too slow on large directories
Start from a narrower path (/var, /home, or a project directory) before scanning /. You can also raise the size threshold to reduce result volume.

Output is too noisy to interpret quickly
Pipe to sort -rh | head -n 10 to focus on the largest entries first.

FAQ

How do I find files larger than a specific size? Use the find command with the -size option. For example, find / -xdev -type f -size +500M finds all files larger than 500 MB. The suffixes k, M, and G represent kilobytes, megabytes, and gigabytes.

What is the difference between find and du for finding large files? The find command locates individual files that match a size threshold. The du command calculates the total disk space used by directories, which helps identify where space is being consumed even if no single file is very large.

How can I find large files modified in the last 7 days? Combine the -size and -mtime options: find / -xdev -type f -size +100M -mtime -7. The -mtime -7 flag matches files modified within the last 7 days.

Is there an interactive tool for finding large files? Yes. The ncdu (NCurses Disk Usage) utility provides an interactive, text-based view of disk usage. Install it with your package manager (sudo apt install ncdu or sudo dnf install ncdu) and run ncdu / to browse the file system by size.

Conclusion

We have shown you how to find the largest files and directories using the find and du commands. To remove files you no longer need, see our guide on how to remove files and directories using the Linux command line .

Tags

Linuxize Weekly Newsletter

A quick weekly roundup of new tutorials, news, and tips.

About the authors

Dejan Panovski

Dejan Panovski

Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.

View author page