Getting the top disk usage files/directories is a common use case and we need to often use it to find them out.
Here is a handy tip on how to find top 10 directories/files based on the disk usage
Here is the syntax
$du -a <based folder> | sort -n -r | head -n <number of files>
Here we replace base folder to the location where we want the search to run and number of files specifies how many files do we want. It would be 10 for top 10 files.
Let’s see a sample example
$du -a /var/ | sort -n -r | head -n 10