Monday, April 11, 2011

Find the disk space used by a user

To find the disk space being used by a single user, you need to combine du with the find command to only report disk usage for a specific user:

$ find . -user username -type f -exec du -k {} \;

To get total disk used

$ find . -user username -type f -exec du -k {} \;|awk '{ s = s+$1 } END { print "Total used: ",s }'

You use the same principle with groups using the -group option to find

find . -group mcslp -type f -exec du -k {} \;|awk '{ s = s+$1 } END { print "Total used: ",s }'

No comments:

Post a Comment