One of the things I find that I need to do every now and then is find out how much space a particular directory is taking up on the hard drive. This is fairly easy to do using a file browser such as konqueror as you simply right click on the directory and select properties. Quite often though I need to perform the same task from the command line (typically because something has gone sideways and filled up a drive - sigh).
Directory Size
The command to use is situation is du and various useful examples of this command are shown below. The man page, of course, provides full coverage.
du
Entering just du will provide you with a pretty comprehensive output of the size of the current directory and every directory under it in a recursive manner. The displayed size is in kilo bytes and is listed for each directory. Personally, I find this less than useful and I think a better default action would be the command shown below.
du --max-depth=1 -h
This version of du will list the total size of each directory under the current directory but only recurse one level deep. It will also display the sizes in a human readable format (e.g. megabytes, gigabytes, etc)
du /foo/bar
Useful when you only want to know about one particular directory.
du -a
Prints out the size of every file and directory under the current directory - be prepared for a lot of output.
du -s
Show just a summary for each argument
du -S
Don't include the size of sub-directories in the total. This gives you the size of just the files in the current directory.
Drive Size / Used Space
If you want to find out how much space you are using on a drive use:
df -h