[Linux]How to get top directories/files based on disk usage

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

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.