Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is it possible to list the largest files on my hard drive? I frequently use df -H to display my disk usage, but this only gives the percentage full, GBs remaining, etc.

I do a lot of data-intensive calculations, with a large number of small files and a very small number of very large files. Since most of my disk space used is in a very small number of files, it can be difficult to track down where these large files are. Deleting a 1 kB file does not free much space, but deleting a 100 GB file does. Is there any way to sort the files on the hard drive in terms of their size?

Thanks.

share|improve this question
add comment

4 Answers

up vote 3 down vote accepted

With standard available tools:

To list the top 10 largest files from the current directory: du . | sort -nr | head -n10

To list the largest directories from the current directory: du -s * | sort -nr | head -n10

share|improve this answer
3  
For your first option, can't you just list them with ls -Sl | head? –  Bernhard Apr 24 '12 at 18:23
    
No, du traverses the whole directory tree, whereas ls -S only checks the current directory. –  jippie Jun 5 '12 at 17:25
add comment

Try ncdu, as it can give you an overview of disk usage. From its website:

A disk usage analyzer with an ncurses interface, aimed to be run on a remote server where you don't have an entire gaphical setup, but have to do with a simple SSH connection. ncdu aims to be fast, simple and easy to use, and should be able to run in any minimal POSIX-like environment with ncurses installed.

share|improve this answer
add comment

There is a simple and effective way to find size of every file and directory in Ubuntu:

Applications > Accessories > Disk Usage Analyzer

in this window click "Scan Filesystem" button on toolbar. after a short time (seconds) you have disk usage of every directory and file.

share|improve this answer
add comment

You can try with this command, it will list all files larger than 20Mb.

find / -type f -size +20000k -exec ls -lh {} \; 2> /dev/null \
  | awk '{ print $NF ": " $5 }'  | sort -hrk 2,2
share|improve this answer
3  
If the biggest file on your filesystem is 20MB, you probably wouldn't be running low on disk space. At least with any HD made this millenium –  Kevin Apr 24 '12 at 17:15
    
That's only example, you put there whatever you want. It will find everything bigger than 20MB, not only 20MB files. –  patseb Apr 24 '12 at 19:25
    
ls -lh then sort?? ls -s or stat -c %b are probably better. –  Mikel Apr 24 '12 at 19:54
    
I don't get. My example use ls, and sort. He wanted to find files over whole disk not directory. –  patseb Apr 24 '12 at 19:57
add comment

Your Answer

 
discard

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.