Linux display the largest folders files including the sub-directories
- By Preneesh AV --
- 13-Mar-2019 --
- 120 Comments
find -type f -exec du -Sh {} + | sort -rh | head -n 5
The command parameters are.
du
command: Estimate file space usage.a
: Displays all files and folders.sort
command : Sort lines of text files.-n
: Compare according to string numerical value.-r
: Reverse the result of comparisons.head
: Output the first part of files.-n
: Print the first ānā lines. (In our case, We displayed first 5 lines).
Run the following command to find out top biggest directories under /home
partition.
# du -a /home | sort -n -r | head -n 5
To display the largest folders/files including the sub-directories, run:
du -Sh | sort -rh | head -5