Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a lot of home folders under /home/ and I would like to get the total size of each users folder in an easy to read list.


  1. /home/user1 100MB
  2. /home/user2 24MB
  3. /home/user3 54MB


Currently using something similar to du -hc | grep total

share|improve this question
how does 'du -hc' not provide your answer already? – ericslaw Jul 20 '09 at 19:49
up vote 1 down vote accepted

IMO, a merge of the answers by Ernie and Depesz is closest to what you asked for, except that it should be 'du -s /home/*/ | sort -n'. 'du -h' doesn't sort properly with 'sort -n', because it's not really a number any more, e.g. 10G sorts before 10M

another alternative, if you want to find out the total disk space used by each user regardless of whether it's in their home directory or not is to install the quota utils, enable quota accounting on the relevant filesystem(s), but leave each users' quota at 0 (unlimited). that will tell you disk space used as well as the number of files/inodes used.

then you can just run 'repquota -a' to get a report like this:

*** Report for user quotas on device /dev/sda8
Block grace time: 7days; Inode grace time: 7days
                        Block limits                File limits
User            used    soft    hard  grace    used  soft  hard  grace
user1     --   67844       0       0           7748     0     0
user2     --   21908       0       0           1742     0     0
user3     --   27212       0       0            258     0     0
user4     --   25492       0       0            328     0     0
user5     --  575536       0       0           2972     0     0
user6     --   83944       0       0           1114     0     0
user7     --  501304       0       0           3418     0     0
user8     --  760068       0       0           5011     0     0
user9     -- 1445396       0       0           1932     0     0

repquota also has a "-s" option for "human readable" output, like du's "-h". not surprisingly, it has the same sorting problem as du -h, though.

share|improve this answer
This works great, thanks! – somabc Jul 21 '09 at 22:53
du -hcs /home/*/

Or, for exactly what you want:

for i in /home/*/; do 
    space=$(du -hs "$i" | cut -f1)
    echo "${user%/} = $space" 
share|improve this answer
Well its not 'exactly what you want' if you go and change the question on me :-) – Kyle Brandt Jul 20 '09 at 19:23
If the owner of the folder is always the user, you could replace the user= line with: user=$(stat -c "%U" "$i") and the just echo "$user = $space" --That might be a bit cleaner. If you want line numbers, you can add ' | cat -n' after 'done' or just increment a variable each time in the loop. – Kyle Brandt Jul 20 '09 at 19:38
sorry was trying to make the formatting easy to read, thanks for your help I'll try it tomorrow. – somabc Jul 20 '09 at 20:49

What are you trying to find out?

If you're looking to sort by size, try this:

du -s /home/ |sort -n
share|improve this answer

just run this:

du -sh /home/*

And you should be happy.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.