Finding disk space used by specific user in Linux and UNIX server

To find the disk space being used by a specific user:


# find . -user user1 -type f -exec du -k {} \;


Explanation of this command:


The -user option allows you to specify that find will only report files that are owned by the specified user. 


The -type option forces find to only return the path of items of a specific type (in this case, files). this prevents du from including directories, which might be owned by one user, but contain files for many users.


Then, for each found path, the du command is executed to report the disk usage.


To get summary information, i.e the total space used by a specific user:



# find . -user user1 -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 dba -type f -exec du -k {} \;|awk '{ s = s+$1 } END { print "Total used: ",s }'

Share this

Related Posts

Previous
Next Post »

2 comments

Write comments
October 1, 2012 at 6:15 PM delete

nice command but i need fasterly check is there any script please help me out i m provding my emaill id manju.hosmane@gmail.com i hope i ll get reply

Reply
avatar
October 1, 2012 at 9:24 PM delete

Manjunath,

You can create a script with command in the article easily. Reach me in email, if you need help to create a script

Reply
avatar

What do you think about this Article? Add your Opinion..! EmoticonEmoticon