Here’s a lovely command for figuring out how much disk space each folder on a drive consumes. It is an excellent command to run if the currently logged in user does not have sufficient read permissions to view the used space on the directory in the Finder.
By default it runs on the current directory. So navigate to the hard drive’s root folder and run this command:
sudo du -xhd 1
In this case, the “x” instructs the system not to traverse file system mount points (so /Volumes is skipped), the “h” expresses results in human readable format (G for gigabytes, M for megabytes, K for kilobytes, B for bytes, etc.), and the “d -1” argument instructs the operation to only look to a depth of 1 folder (so child folders are not shown).
This is especially helpful for getting sizes for folders that the Finder normally ignores (etc, bin, private, etc.).
This command can also be handy in Apple Remote Desktop for looking at disk usage within user folders on client machines. Send the following Unix command to client machines:
du -xhd 1 ~/
… and run it as the logged-in console user (running as root will have the effect of looking at root’s home folder!). You can instantly see where users’ data is taking up the most space.
krypted November 3rd, 2005
Posted In: Mac OS X, Mac OS X Server, Unix