Find Large Files in Linux

In the following simple solution, I cover how to Find Large files in Linux. This process was tested from a running Ubuntu Linux environment. It’s good to know which files are taking up the most space as disk space fills up. It’s often necessary to locate largest files when you start running out of disk space, and need to perform a cleanup to remove unnecessary files in order to make space for some new files.

Finding the Largest Files in Linux

  1. Open up a terminal and change directory cd to where you’d like to start your base search for the largest files.
  2. Type find -type f -exec du -h {} + | sort -hr | head -8 and press Enter find large files linux

The files are located and sorted by largest size first and displayed in the terminal window.

How it works: This process works by first finding all files starting at the base directory including its sub-folders. The files are then probed for their disk usage via du, set to display size in -h (human readable format). The files are then sorted in -h (human readable format) in -r (reverse order) largest first. Finally head is run to output the number of results (-#) , in lines that we want to return. In this example 8.

Note: If the user running the command doesn’t have permission to access a file, you’ll get permission denied errors.

This concludes the simple tutorial to Find Large Files in Linux