Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Linux command to find largely disk space utilized file. I need to list all files in the order of size

share|improve this question

migrated from Nov 27 '10 at 5:31

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

Belongs to – EboMike Nov 27 '10 at 5:13
du -k | sort -rn | head -n 50


  • The du utility displays the file system block usage for each file argument and for each directory in the file hierarchy rooted in each directory argument. If no file is specified, the block usage of the hierarchy rooted in the current directory is displayed. -k will display block counts in 1024-byte (1-Kbyte) blocks.

  • sort is self-explanatory. -r reverses the result of comparisons, placing the highest value atop the list. -n compares according to string numerical value.

  • head only shows the top n rows. 50 in this case.

share|improve this answer

Always keep something like this tucked away in an alias somewhere:

find / -type f | xargs ls -s | sort -rn | awk '{size=$1/1024; printf("%dMb %s\n", size,$2);}' | head
share|improve this answer
expensive as ls is called on every individual file. -printf instead of xargs resolves that. – pbr Nov 27 '10 at 5:40

Here you go.

For the / device, and only for that device, this prints the 500 largest files with their size in megabytes. Omit the "head -n 500" and it'll print all files with sizes, sorted largest first.

find / -xdev -type f -printf "%s %h/%f\n" | sort -rn -k1 | head -n 500 | awk '{ print $1/1048576 "MB" " " $2}'
share|improve this answer

You must log in to answer this question.