Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

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
up vote 615 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
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
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
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 '14 at 19:58
Incredible tool! – Ted Feb 3 '15 at 3:43
That tools is just amazing! Wau, I've been wanting this for a long time! :D Thank you!! – WoodyDRN Dec 10 '15 at 8:00
very cool tool! – whytheq Jul 11 at 20:14


du foldername

More information on that command here

share|improve this answer

This finds the size recursively and puts it next to each folder name, along with total size at the bottom, all in the human format

du -hsc *
share|improve this answer

tree is another useful command for this job:

Just install it via sudo apt-get install tree and type the following:

tree --du -h /path/to/directory

33.7M used in 0 directories, 25 files

From man tree:

-h    Print  the size of each file but in a more human readable way, e.g. appending a size letter for kilo‐
      bytes (K), megabytes (M), gigabytes (G), terabytes (T), petabytes (P) and exabytes (E).

--du  For each directory report its size as the accumulation of sizes of all its files and  sub-directories
      (and their files, and so on). The total amount of used space is also given in the final report (like
      the 'du -c' command.)
share|improve this answer

The answers have made it obvious that du is the tool to find the total size of a directory. However, there are a couple of factors to consider:

  • Occasionally, du output can be misleading because it reports the space allocated by the filesystem, which may be different from the sum of the sizes of the individual files. Typically the filesystem will allocate 4096 bytes for a file even if you stored just one character in it!

  • Output differences due to power of 2 and power of 10 units. The -h switch to du divides the number of bytes by 2^10 (1024), 2^20 (1048576) etc to give a human readable output. Many people might be more habituated to seeing powers of 10 (e.g. 1K = 1000, 1M = 1000000) and be surprised by the result.

To find the total sum of sizes of all files in a directory, in bytes, do:

find <dir> -ls | awk '{sum += $7} END {print sum}'


$ du -s -B 1

$ find .  -ls | awk '{sum += $7} END {print sum}'
share|improve this answer
The find-ls-awk will return a wrong value for large folders #1. For newer awk you can add --bignum or -M ; if that is not an option use find . -ls | tr -s ' '|cut -d' ' -f 7| paste -sd+ |bc #2. – goozez Jun 29 at 20:25

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

man du

read man page before you use the command.

share|improve this answer

For only Directory size on readable format use below:

du -hs directoryname

This probably isn't in the correct section, but from the command line, you could try:

ls -sh filename

The -s is size, the -h is human readable.

Use -l to show on ls list Like below:

ls -shl
share|improve this answer

The best one I think is the following:

du -h directory_name | tail -n1

This will show you only the size of the directory that you are interested in and will not print sizes of any directories and files inside that directory.

I should add that if the size of the folder is large then du takes longer time. You must be patient for this command to work. Just like any other unix command, you may find out the total time for this process by using time before this command:

time du -h directory_name | tail -n1
share|improve this answer
du has an option for this: -s – muru Oct 4 '15 at 11:46

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.