System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Script to look for .rhosts file in every home directory

SOLVED
Go to solution

Script to look for .rhosts file in every home directory

Hello team,

I'm not used to scripting, could you give me some ideas to look for .rhosts file in every home directory of the server?

It's running HPUX 11.00.

Thanks in advance.
7 REPLIES
Pete Randall
Outstanding Contributor
Solution

Re: Script to look for .rhosts file in every home directory

try this:

find /home -name .rhosts


Pete

Pete
Pete Randall
Outstanding Contributor

Re: Script to look for .rhosts file in every home directory

or even just

ll /home/*/.rhosts


Pete

Pete
Mel Burslan
Honored Contributor

Re: Script to look for .rhosts file in every home directory

for homedir in `cat /etc/passwd | cut -d: -f6`
do
ls ${homedir}/.rhosts > /dev/null 2>&1
result=${?}
if [ $result -eq 0 ]
then
echo "+++$homedir has a .rhosts file"
else
echo "---$homedir doesn't have a .rhosts file"
fi
done

hope this helps.
________________________________
UNIX because I majored in cryptology...

Re: Script to look for .rhosts file in every home directory

Thanks a lot Pete! sometimes simplier is better.
Mel Burslan
Honored Contributor

Re: Script to look for .rhosts file in every home directory

Nancy,

there are some oddball user names which come with some application installations, requiring their home directories to be somewhere outside /home, which may not be covered by searching the /home only. This is why my more complex method goes thru the password file.
________________________________
UNIX because I majored in cryptology...

Re: Script to look for .rhosts file in every home directory

Thanks a lot Mel, I didn't mean to bother you, of course your script is quite useful, I was just testing it before to answer.

Re: Script to look for .rhosts file in every home directory

...