Linux How To Find Large Files
If you are running out of disk space or just want to keep on top of storage you are likely to find yourself searching for large files. Fortunately there are tools that can help you with this on Linux.
Quick Answer: This will find the top 10 largest files in the current directory ( including sub directories ):
du -a /home/user1 | sort -nr | head
The du command will show disk usage. Using the “-a” parameter will return sizes for everything ( files and directories ) instead of just directories. This will give us a lot of data by itself. We can pipe the output of this command to the sort command. We use the “-nr” parameters to sort by number and in reverse ( largest first ). We can now pipe all of this to the head command which will limit the output to the first 10.
Filtering out Errors
If you are seeing a lot of errors ( permission denied, etc. ) you can filter these out. This will potentially happen if you are searching from the root of your filesystem like this.
sudo du -a / 2>/dev/null | sort -n -r | head -n 20
If you don’t care about sorting or limiting the number of results you can just use the DU command by itself. You can also specify that it shows you human readable output with the “-h” parameter.
Here is another example checking my home directory:
du -ah /home/user1