Sharing Knowledge | System Admin Articles

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 }'



Labels: Linux, Tips, UNIX

My Profile PhotoAbout the Author

I'm Parthiban, An UNIX System Admin by Profession. I'm Experienced in Linux/Unix System Administration and Scripting. I have done lot of work on the infrastructure Mgmt side in Linux, UNIX and Windows system administration, Hardware, Storage and Data center. I'm blogging since 2008.
Follow Me On Twitter or On Facebook

2 Comments for "Finding disk space used by specific user in Linux and UNIX server"

nice command but i need fasterly check is there any script please help me out i m provding my emaill id [email protected] i hope i ll get reply

Manjunath,

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

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

Back To Top