Wednesday, January 5, 2011

How to list or find the largest files, directories and Free disk space

♦ Find biggest top 10 directories in your disk

du -hs */ | sort -nr | head

♦ Find the biggest files inside directories

ls -lhS | head

♦ Find biggest files in any directory recursively

We’ll now use find, to find only files, and then sort, to have only the biggest files listed.

find -type f -ls | sort -k 7 -r -n | head -5

find helps us list only files and not directories, then sort using the column 7 (the column with the file size) we sort using -n numeric order and -r reverse order (from biggest to smallest), and finally only the first 5 files in the current directory, and sub-directory.

You can use this way

find / -type f -ls | sort -k 7 -r -n | head -5
And that will work, for all disk from root. 

du Summarize disk usage of each FILE, recursively for directories.
sort Write sorted concatenation of all FILE(s) to standard output.
head Print the first 10 lines of each FILE to standard output. With more than one FILE, precede each with a header giving the file name. With no FILE, or when FILE is -, read standard input.


No comments:

Post a Comment

There was an error in this gadget