Linux – how to find per-user disk-space-usage


I am writing a small tool in which I require to find per-user File-system-memory-usage.

I have to do some clean up activity if file-system usage is crossing certain threshold value. What is the system call that I can use, so that I could be able to find per user memory usage?

Best Solution

A simplistic approach would be

du -shc /home/*

To sort it:

du -smc /home/* | sort -n

There is also a wellknown Perl script that has the option of mailing disk usage reports per user: durep