Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Under Linux, I'm looking for a command to list the biggest file and/or the biggest directories under a directory.

share|improve this question
This should be on superuser. –  supercheetah Apr 28 '11 at 13:43
add comment

migrated from stackoverflow.com Apr 28 '11 at 13:56

This question came from our site for professional and enthusiast programmers.

8 Answers

up vote 3 down vote accepted

From any directory:

du -a | sort -n -r

share|improve this answer
add comment

du --max-depth=1 /path | sort -r -k1,1n shows you one level of directories and their sizes. If one of them really sticks out (the last one on the list is the largest due to sort -r), then you rerun the command on that directory, and then keep going until you find the offending directory/file.

If all you want is the ten biggest files just do find /home -type f -exec du -s {} \; | sort -r -k1,1n | head

share|improve this answer
biggest number ends up at the bottom for me no matter if I add sort -r or not. Is there a way to get the biggest number at the top? –  squarecandy Oct 27 '13 at 22:17
You must indicate to sort which column you want to sort by, and that it's numeric (not alphanumeric). That's what -k1,1rn would do. By default sort does uses alphanumeric sort on first column. –  Marcin Oct 28 '13 at 12:45
Yes, it's sorting correctly with that, but it's in ascending order low to high numbers no matter if I include sort or sort -r. Am I misunderstanding how the -r works? I guess it's not a big deal. Your example is very helpful and got me the info I needed. –  squarecandy Oct 28 '13 at 16:17
With the sort I have (sort (GNU coreutils) 8.13 in Ubuntu 12.04.3) the option -r does not work if -n immediately follows -k (-k1,1n). This order of options works: sort -rnk1,1. –  pabouk Dec 1 '13 at 8:26
add comment

du -sk * | sort -nr | head -1

This will show the biggest directory/file in a directory in KB. Changing the head value will result in the top x files/directories.

share|improve this answer
add comment

A utility called 'ncdu' will give you the information you are looking for.

sudo apt-get install ncdu
share|improve this answer
add comment

Use du. Try this to order the result:

du | sort -n
share|improve this answer
add comment

this post will help you well:

cd /path/to/some/where
du -a /var | sort -n -r | head -n 10
du -hsx * | sort -rh | head -10
share|improve this answer
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. –  Carl B Dec 1 '13 at 5:57
Yeah,I think you are right! thanks for hint –  matthew xiang Dec 1 '13 at 6:13
add comment

du -a -h /path | sort -h -r | head -n 10

I like to use -h options for readability. Both du and sort need to have -h.

share|improve this answer
add comment
du -sh /path * | sort -nr | grep G

G for GIG (to weed out smaller) files/directories

share|improve this answer
This lists all the files and folders, showing the size. It doesn't sort the size by the K, M or G's worth of bytes, unless you GREP it as you shown –  Canadian Luke Oct 15 '13 at 17:31
Also it will find anything with a G in the file's name. –  Kevin Panko Oct 15 '13 at 18:03
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.