Display disk usage with the du command

How to display the total of the current directory or a particular directory, as well as listing subtotals (subdirectories).

Occasionally it can be very helpful to know how much data is stored in a particular directory in the file system.

You can use the following command to check how much data the current working directory contains.

$ du -sh

Similarly, you can check how much is used in a specific directory if you specify it after the option flags as follows.

$ du -sh ~/Dropbox

If you want to list the size of each subdirectory in a particular directory, you can use the following instead.

du -h --max-depth=1 ~/Dropbox

However, if you're on a Mac, the command is slightly different.

du -hd 1 ~/Dropbox