Wednesday, April 21, 2010

LINUX: Checking total size of directories

To find the total usage per user for their home directory without finding info on each subfolder, use the du command specifying the max-depth to be = 1 so that subdirectories are not shown on the screen, but they are still calculated in the total.
$ du -h --max-depth=1

Then to sort this list, redirect it to a file such as mysize and run the following to get an ascending list of offenders in the hundreds of MB:
$ du -h --max-depth=1 > mysize

$ grep -e [0-9][0-9][0-9]M mysize | sort

And of course run a simple grep G mysize to see gigabyte offenders.

No comments:

Post a Comment