How do I determine the total size of a directory (folder) from the command line?

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)

As you're using -h you can sort the human readable values using

du -h | sort -h

The -h flag on sort will consider "Human Readable" size values.


If want to avoid recursively listing all files and directories, you can supply the --max-depth parameter to limit how many items are displayed. Most commonly, --max-depth=1

du -h --max-depth=1 /path/to/directory

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

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 *