Checking space used by directories

More advanced tricks and tips for using UNIX and Linux.

Checking space used by directories

Postby UnixMan » Thu Jan 28, 2010 8:49 pm

On all Unix and Linux systems, you can check the space used by all directories below your current directory, with the following command:
Code: Select all
du -k .
(note the dot on the end, with a space between the 'k' and the dot. The dot indicates 'the current directory', but you could put any directory name there.

The output will be, for example:
Code: Select all
9435    ./Pictures/holidays
11021   ./Pictures/family
21253   ./Pictures
1719    ./Documents
11230   ./Data


The values are in Kilobytes, so in other words there are approximately 21MB in Pictures, 1.7MB in Documents, and 11MB in Data. Note how all subdirectories are displayed.

If you just want to see the 'top level' subdirectories, use something like:
Code: Select all
du -k --max-depth=1 .


As always, look at the full help to see what other options may be useful, with:
Code: Select all
du --help
UnixMan
Site Admin
 
Posts: 103
Joined: Sat Jul 31, 2004 11:13 am

Advertisement

Return to Tips and Tricks - intermediate and advanced

Who is online

Users browsing this forum: No registered users and 1 guest

cron