Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is there a simple command to display the total aggregate size (disk usage) of all files in a directory (folder)?

I have tried these, and they don't do what I want:

  • ls -l, which only displays the size of the individual files in a directory, nor
  • df -h, which only displays the free and used space on my disks.
share|improve this question

4 Answers 4

up vote 256 down vote accepted

The command du "summarizes disk usage of each FILE, recursively for directories," e.g.,

du -hs /path/to/directory
  • -h is to get the numbers "human readable", e.g. get 140M instead of 143260 (size in KBytes)
  • -s is for summary (otherwise you'll get not only the size of the folder but also for everything in the folder separately)
share|improve this answer
    
respect for going the extra mile. :) –  myusuf3 Aug 5 '10 at 18:37
1  
Great answer, that does exactly what I wanted. +1 @Marcel and @garbagecollector. I still have too little rep to upvote, but I'll come back once I hit 15 to get you guys. –  David Barry Aug 5 '10 at 18:42
    
@David you better! :) –  myusuf3 Aug 5 '10 at 18:55
22  
I use du -sh or DOOSH as a way to remember it (NOTE: the command is the same, just the organization of commandline flags for memory purposes) –  Marco Ceppi Aug 5 '10 at 18:56
25  
One more useful bit: du -h --max-depth=1 /path/to/folder Will produce a list of all the folders in /path/to/folder and their sizes. Trying to find the biggest? du --max-depth=1 /path/to/folder | sort -nk1 will organize the list from smallest to largest. –  Marco Ceppi Aug 5 '10 at 19:35

Recently I found a great, ncurses based interactive tool, that quickly gives you an overview about directory sizes. Searched for that kind of tool for years.

  • quickly drilldown through file hierarchy
  • you can delete e.g. huge temporary files from inside the tool
  • extremely fast

Think of it as baobab for the command line:

apt-get install ncdu
share|improve this answer
    
This is absolutely fantastic! Like DaisyDisk, for OSX –  subZero Jun 6 at 19:58

Enjoy!

du foldername

More information on that command here

share|improve this answer

du /foldername is the standard command to know the size of the folder.It is best practice to know the options by reading man page.

man du .

read man page before you use the command.

http://linuxmanpages.com/man1/du.1.php

share|improve this answer

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.