How to Find and List the Largest Files in Your Linux System

Linux TLDR
Last Updated:
Reading time: 3 minutes

Hardly, 10 GB of disk space is used for the Linux operating system, and the rest of the space is occupied by your own files when you set up a new Linux system.

Sadly, more disk space is consumed over time when your system gets cluttered with a lot of unnecessary files, mostly due to large log or backup files.

However, you have the find and du commands that can help you estimate the file size in your current working directory or whole system, and by piping another command, you can list them based on their size.

In this tutorial, you will learn how to find and list the largest files and directories in your Linux system using the “find” and “du” commands.

Tutorial Details

DescriptionSearching for Largest Files in Linux
Difficulty LevelModerate
Root or Sudo PrivilegesYes (depends upon the path)
Host System and ArchitectureUbuntu 22.10 (x64)
OS Compatibility Ubuntu, Manjaro, Fedora, etc.
Prerequisitesfind, du
Internet RequiredNo
Discussed Tools in this Articlehead, tail, ls, sort, numfmt, rm

Note: All of the examples shown in this article will look for the largest files in the current working directory, or you can replace the (“.“) with the path directory where you want to search for the largest files.

Recursively Find and List the Largest Files using the find Command

The find command is an advanced tool to search for specific files or directories rigorously in your Linux system with different parameters (like based on access time, modification date, permissions, file size, etc).

Also Read: Clean Up Unwanted APT Packages in Linux

The following are a few examples that you can use to find and list the largest files in your Linux system using the find command.

Finding and Listing the Files Greater Than 100 MB

The following command will look for files in your current working directory whose size is greater than 100 MB and then list each one of them with their file information using the ls command.

$ find . -xdev -type f -size +100M -print | xargs ls -lh | sort

Output:

Finding the file bigger than 100 MB in current working directory
Finding the file larger than 100 MB in the current working directory

Command breakdown:

  • find . -xdev -type f -size +100M -print“: It will only search for (-type f) regular files in the (“.“) current working directory within the (-xdev) same filesystem with (-size +100M) sizes greater than the 100 MB.
  • xargs ls -lh“: It will take the results from the find command and list each file in newlines with more details.
  • sort“: Sort the file.

Finding and Listing the Top 10 Largest Files

The following command will recursively search for all files in your current working directory and list the top 10 files with the largest size from top to bottom using the find command.

$ find . -type f -printf '%s %p\n' | sort -nr | head -10

The following will give you the same result as above but print the size in a human-readable format.

$ find . -type f -printf '%s %p\n' | sort -nr | head -10 | numfmt --to=iec-i --suffix=B --format="%.3f"

Output:

Finding and listing the top 10 largest file
Finding and listing the top 10 largest files

Command breakdown:

  • find . -type f -printf '%s %p\n'“: It will search for the (-type f) regular files in the (“.“) current working directory by interpreting the ('%s %p\n') name and size of the file in bytes.
  • sort -nr“: Sort the files based on their size in reverse order.
  • head -10“: Prints only the first 10 lines of the piped output.
  • numfmt --to=iec-i --suffix=B --format="%.3f"“: Display the size in human-readable format.

Finding and Listing the Largest File Using the du Command

The du command is used to estimate and summarize file and directory space usage, which can also help you find the largest file in your Linux system.

The following command will print the 10 largest files in your current working directory.

$ du -ahx . | sort -rh | head -10

Output:

Finding and listing the top 10 largest files using the du command
Finding and listing the top 10 largest files using the du command

Command breakdown:

  • du -ahx .“: It will search for regular files in your (“.“) current working directory within the same file system in human-readable format.
  • sort -rh“: Sort the files based on their size and reverse the order (listing the largest first).
  • head -10“: Prints only the first 10 lines of the piped output.

Final Tip!

Once youโ€™ve caught the largest files consuming the most disk space in your Linux filesystem, you can perform the next step, like removing that file (you must be aware of the file usage) or moving it somewhere else.

Although I tried to cover the most reliable commands that will help you find and list the largest file in your system, if you have any more examples that should be included in this article, then do let us know in the comment section.

Join The Conversation

Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.