Operating System - HP-UX
1834869 Members
2437 Online
110070 Solutions
New Discussion

Find out login name in hpux system who own files ?

 
SOLVED
Go to solution
Sammy_2
Super Advisor

Find out login name in hpux system who own files ?

Need a command to show me the all unix login name who own files on hpux system ?
good judgement comes from experience and experience comes from bad judgement.
9 REPLIES 9
RAC_1
Honored Contributor

Re: Find out login name in hpux system who own files ?

logins -u will give you the user logins on your system.

Then you can do

find . -user "user_name" -type f -exec ll {} \;
find . -user "user_name" -type d -exec ll {} \;

The find command may burn a CPU lot.

Anil
There is no substitute to HARDWORK
Pete Randall
Outstanding Contributor

Re: Find out login name in hpux system who own files ?

You could run a find and exec ll then pipe it to sort on user.

find /dirname -exec ll {} \; |sort -mu


Pete

Pete
Sundar_7
Honored Contributor
Solution

Re: Find out login name in hpux system who own files ?

I dont believe there is a single command that can achieve this.

logins | awk '{print $1}' | xargs -n1 | while read USER
do
NUM=$(find / -user $USER | wc -l)
[ $NUM -gt 1 ] && echo "$USER" > /tmp/users_who_own_files.txt
done

more /tmp/users_who_own_files.txt
Learn What to do ,How to do and more importantly When to do ?
Rodney Hills
Honored Contributor

Re: Find out login name in hpux system who own files ?

The "diskusg" command can be run on a file system to produce a summary of users and their disk usage. Do a "man diskusg" for more detail.

example to display /tmp-
diskusg /dev/vg00/lvol5

HTH

-- Rod Hills
There be dragons...
Sanjay_6
Honored Contributor

Re: Find out login name in hpux system who own files ?

Hi,

Have you tried "listusers". This will list all the users on the system. Almost the same as "logins -u".

Hope this helps.

Regds
Sammy_2
Super Advisor

Re: Find out login name in hpux system who own files ?

RAC- on the right path, but seems like i have to do this for each user in passwd file
Pete- kind of works but it gives me 1000 of files (and lines) for user like oracle. I just need to know what user have at least one file as being owned. Little tweaking from your command will possibly give me the output.
Sundar- time consuming but finally i will get the output. you forgot >> instead have >.
Rodney- nice command but need to do on each disk and then sort it
Sanjay- nice command to list users in a nice format but I see some users there that don't own any files. Thanks to all though.
good judgement comes from experience and experience comes from bad judgement.
Rodney Hills
Honored Contributor

Re: Find out login name in hpux system who own files ?

To use "diskusg" on multiple filesystems and produce a single summary, the man page shows a sample of-

for i in /dev/vg*/lvol* ; do
diskusg $i > dtmp.`basename $i` &
done
wait
diskusg -s dtmp.* >summaryreport

(with some minor editting by me)

HTH

-- Rod Hills
There be dragons...
Muthukumar_5
Honored Contributor

Re: Find out login name in hpux system who own files ?

We can do this by parallel as,

# for user in `listusers | awk '{ print $1 }'`
> do
> echo "$user `find / -user $user -name "*" | wc -l`" >> /tmp/testlog.user &
> done

It will execute at once. To know the directory disk size easily then use,

du -ks
It will give the user directory size there.
Easy to suggest when don't know about the problem!
Sammy_2
Super Advisor

Re: Find out login name in hpux system who own files ?

Thanks to all . The customized scripts work.
good judgement comes from experience and experience comes from bad judgement.