Disk usage per user in Linux / Unix
Solution 1:
Is this a one time thing, or is this information you want to be able to extract regularly? In case it is the later then one option is to apply quotas on your filesystem. Doing that the system continuously keeps track of the amount of data used by each user. That way the information is merely a query to the quota database away.
Solution 2:
Another nice solution I found here. Navigate to the directory of interest, and run (alternatively, change .
to whichever directory interests you, e.g., /home/
):
find . -type f -printf "%u %s\n" \
| awk '{user[$1]+=$2}; END{for(i in user) print i,user[i]}'
Solution 3:
Here is a simple and quick solution that I believe meets your requirement.
I assume that all your users have accounts in the /home directory. All you need to do is to change directory to the /home directory, and then do a du at a depth of 1.
cd /home
sudo du -d 1 -h
Your output will look something like this:
kcyow@linux-server:/home$ sudo du -d 1 -h
7.8M ./user932
52G ./user575
20K ./user329
98G ./user323
48G ./user210
148G ./user44
12M ./kcyow
362G ./user28
24G ./user774
6.2M ./user143
730G .