Operating System - HP-UX
1834625 Members
3269 Online
110069 Solutions
New Discussion

Re: /var/adm/ files owner and group

 
Justin Willoughby
Regular Advisor

/var/adm/ files owner and group


I kind of messed up my lpsched process by changing the permissons of all files under /var/adm today:

chown -R adm:adm /var/adm/*

I fixed /var/adm/lp and my lpsched process is ok now. What I need to know is what else might I have screwed up! Looking on another box I see different files with root,bin,sys owner or group. Should I try to go though one by one and set them to the same as my other box?

I am going live on this box tomorrow and I hate for something else to be broken that I don't know about yet.

Thanks,

- Justin
9 REPLIES 9
V. Nyga
Honored Contributor

Re: /var/adm/ files owner and group

Hi ,

sorry, but I think 'yes'.
There are directories like 'cron' and much log-files which belong to 'root'.
Some with 'rw----' permissions!

Also check if your command also screwed up linked files like /etc/rc.log and shutdownlog.

... sometimes a backup tape isn't so bad.

Volkmar
*** Say 'Thanks' with Kudos ***
Justin Willoughby
Regular Advisor

Re: /var/adm/ files owner and group

I do have backups but I did not know if that would be any more easy then fixing the permissions by hand.

- Justin
RAC_1
Honored Contributor

Re: /var/adm/ files owner and group

I think you can list the file/dirs on the host, where the perms are OK and then do the same thing on this host.

You can put a script for this.

Something like this.
On host where perms are OK.
find /var/adm -type f -exec ll {} \;|awk '{print $3, $4, $NF}' >> /tmp/file.list

Now on the host, you have problem.
for i in $(cat /tmp/file.list)
do
find . -type f -name $(cat /tmp/file.list|awk '{print $NF}' -exec chown "$(cat /tmp/file.list|awk '{print $1}':$(cat /tmp/file.list|awk '{print $2}'" {} \;
done

Not tested yet.

Anil
There is no substitute to HARDWORK
David Child_1
Honored Contributor

Re: /var/adm/ files owner and group

Justin,

If you are patient you could do it by hand, but some stuff may get missed. Way back when I first started I ran a 'chown -R newuser .*' on a Solaris box. I had wanted to change all the .[a-z]* files in my home directory. I was root :( and it did change those files, but it also recursively changed '..' all the way up. I learned two valuable things;

1. be careful with wild cards, escecially when specifying '.'
2. have a good backup :)

(also only use root when required :)

I didn't have a good backup so I spent the next several hours going through all the permisions in /export/home, /export, and /. I was able to get the system in working order in the end.

David
Justin Willoughby
Regular Advisor

Re: /var/adm/ files owner and group

RAC,

I was just thinking of using ls -l and awk to create a script after the first reply. I do have a good system to look at.

All, thanks for everyones reply. I usally don't do silly stuff like this but I was not thinking this time.

- Justin
Robert Salter
Respected Contributor

Re: /var/adm/ files owner and group

Another way using some of Rac's suggest.

On good server do the
find /var/adm -type f -exec ll {} \;|awk '{print $3,$4,$NF}' >> /tmp/file.list

Copy the 'file.list' on the bad server and do;
-------
cat /tmp/file.list|while read own grp file
do
if [ -f $file ] #just to chk
then
ll $file #show the old
chown $own:$grp $file
ll $file # show the new
echo "" #easy to read
fi
done >> chg.log # log of chgs
--------

Time to smoke and joke
V. Nyga
Honored Contributor

Re: /var/adm/ files owner and group

HI again,

Roberts's script looks good.

I don't know what kind of backup you have.
I normally use SAM backup, so I can choose one directory to restore.
If the tape is uptodate it would be the savest solution.

HTH
Volkmar
*** Say 'Thanks' with Kudos ***
Robert-Jan Goossens
Honored Contributor

Re: /var/adm/ files owner and group

Hi Justin,

There is an other way.

# swlist

HPUXEng64RT B.11.00 English HP-UX 64-bit Runtime Env

# swlist -l file -a type -a mode -a owner -a group HPUXEng64RT | grep /var/adm

Regards,
Robert-Jan
Ravi_8
Honored Contributor

Re: /var/adm/ files owner and group

Hi

How about this one

#cp /usr/newconfig/var/adm/* /var/adm
never give up