Operating System - HP-UX
1834704 Members
2817 Online
110069 Solutions
New Discussion

I accidently recursively change ownership on /etc, /stand & /opt

 
Ray Humpage
Frequent Advisor

I accidently recursively change ownership on /etc, /stand & /opt

Is there any way to fix this without going to ignite or looking at another box and changing 1 file at a time? I'm amazed the box didn't crash.
8 REPLIES 8
Torsten.
Acclaimed Contributor

Re: I accidently recursively change ownership on /etc, /stand & /opt

What is the current user?

Most of the files are owned by root:sys, root:root or bin:bin.

The best way to restore it is ignite, anyway.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Ray Humpage
Frequent Advisor

Re: I accidently recursively change ownership on /etc, /stand & /opt

The user was a peoplesoft user.

The problem is since the ignite yesterday I've added lv's to vg00 and the other vg's. I've also made changes to other files. Anyway to pick and choose what I restore?
Keith Clark
Valued Contributor

Re: I accidently recursively change ownership on /etc, /stand & /opt

Check out the swconfig and swverify commands. I have never done this myself, but I believe that you can use one of them to reset the permissions back to original. The man page can be found on docs.hp.com: http://docs.hp.com/en/B2355-90681/swconfig.1M.html and http://docs.hp.com/en/B2355-90681/swverify.1M.html

Worst case scenario is you can get the original permissions from swverify (swverify check_permissions=true) and use the output to script something to set them back...
Bill Hassell
Honored Contributor

Re: I accidently recursively change ownership on /etc, /stand & /opt

Swverify will indeed list all the software distributor packages (primarily HP supplied). The bad news is that a typical system has more than 50 thousand (that's THOUSAND) files and directories that would be trashed. So you're looking at hours to create a script to fix things (the output of swverify is painful to use in a script), and then a couple of days to fix all the applications in /opt that weren't loaded by swinstall. The box will probably run OK because most of the needed files are already open so ownership is no longer important. Restart some apps and you'll have big problems.

This is probably a production machine so Ignite is your only choice simply due to the massive number of modified files. There are two classes of MOST DANGEROUS commands to use in Unix:

# rm,mv,cp -r without the -i option

and

# chown -R or chmod -R

Of course, find with -exec can be disastrous too.


Bill Hassell, sysadmin
Ray Humpage
Frequent Advisor

Re: I accidently recursively change ownership on /etc, /stand & /opt

If I wanted to use the swverify command to check the files out - what would be the syntax that I would use?
Steven E. Protter
Exalted Contributor

Re: I accidently recursively change ownership on /etc, /stand & /opt

Shalom Ray,

As far as the pain index goes, if you have an Ignite or any system backup that includes the three directories, this is far less painful than trying to re-construct from sw-utils.

You might want to build a database of all the files on a similar system (assuming Ignite or backup does not exist) and then change permissions based on that.

Good system.

ls -alR /opt > file.opt
ls -alR /stand > file.stand
ls -alR /etc > file.etc

You can now read these neat little data files and change permission. This will almost certainly work on /etc/ and /stand

/opt will probably require some manual adjustments to work.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Bill Hassell
Honored Contributor

Re: I accidently recursively change ownership on /etc, /stand & /opt

swverify

no parameters needed to look at all the HP software. It won't help with other applications that did not use swinstall.


Bill Hassell, sysadmin
Keith Clark
Valued Contributor

Re: I accidently recursively change ownership on /etc, /stand & /opt

I agree with the others, ignite is the way to go and if you can always take a new one before making any major system changes, so you have a roll back plan. If you don't have one or you do not have another system to blueprint with, you can use the swverify command. It's not a painful as others will lead you to believe, but will only address software installed via sw-tools...

Run "swverify /*". When it completes (probably about 5-15 minutes depending on your system) it will output a swlog command that will allow you to manipulate the output for that particular job. Look for: "NOTE: More information may be found in the agent logfile using the command "swjob -a log - @ :/".

Using this swlog command: swjob -a log - @ :/|egrep "should have group|should have owner"|awk '{print $3,$7}'. You can then use this output to recreate the permissions. If you have file names that are really long, the $7 output of awk may be blank, since the output wrapped. You could spend more time and write a script in perl, but this will give you a good indication of the damage...

Doesn't help you with the permissions for your applications, unless yo are lucky enough that they installed with sw-tools.

Good luck!