Operating System - HP-UX
1830216 Members
1894 Online
109999 Solutions
New Discussion

Re: which user uses maximum disk space

 
SOLVED
Go to solution
Shivkumar
Super Advisor

which user uses maximum disk space

Dear Sirs/Madam;

I want to find out which user is using maximum disk space in /home directory file system.

Can anyone tell which command i should use ?

Thanks,
Shiv
6 REPLIES 6
Rajeev  Shukla
Honored Contributor

Re: which user uses maximum disk space

cd to /home directory and run
du -ks *
This will show you the sizes of each directory (which is users home directory) with their sizes in KB
Ermin Borovac
Honored Contributor

Re: which user uses maximum disk space

If directory is root of the filesystem you can use quot(1M).

# /usr/sbin/quot /home

It will produce disk usage in KB for each user sorted with top users first.
morganelan
Trusted Contributor
Solution

Re: which user uses maximum disk space

Hi,
Try run this:
#du -akx /home|sort -nr|more
This wiil sort from largest to lowest used space under /home dir.
Kamal Mirdad
Devender Khatana
Honored Contributor

Re: which user uses maximum disk space

Hi,

quot is the best way to find out this. Allthough all of the above solutions works to some extent.

But apparently it seems your /home is the only worry for you at this time as you are posting several questions related to this at present. Could you attach "bdf" output and "vgdisplay -v vg00" output.

HTH,
Devender
Impossible itself mentions "I m possible"
Cem Tugrul
Esteemed Contributor

Re: which user uses maximum disk space

Shiv,

i often use to determine max using /home
users and warn them like;

cd /home;
du -ks * |sort -n

and if i want to warn them to delete their
unnecessary files then;

#!/usr/bin/ksh
cd /home;
if [ $? -ne 0 ]
then
echo "/home not found..."
exit 1
fi
for user in `du -ks * |sort -n|tail -10|awk '{print $2}'`
do
echo "Please clean your unnecessary files!!!Contact Shivkumar"|mailx -s "home dir usage" $user@mail_address
done

Above the script;last 10 top disk usage users
will be inform via e-mail

Good Luck,
Our greatest duty in this life is to help others. And please, if you can't
Muthukumar_5
Honored Contributor

Re: which user uses maximum disk space

You can use script like,

#!/bin/ksh

total=$(find /home/ -user root | xargs ls -l | awk 'BEGIN {size=0;}{size+=$5;}END{print size;}')
echo "root user is using $total size in /home"
for user in `ls /home/ | grep -v 'lost+found'`
do
id $user 1>/dev/null 2>&1
if [[ $? -eq 0 ]]
then
total=$(find /home/ -user $user | xargs ls -l | awk 'BEGIN {size=0;}{size+=$5;}END{print size;}')
echo "$user is using $total size in /home"
fi
done

hth.
Easy to suggest when don't know about the problem!