Operating System - HP-UX
1848941 Members
7111 Online
104039 Solutions
New Discussion

How to fix the mistake "chown root *" at root dir /

 
meijuan.ding
New Member

How to fix the mistake "chown root *" at root dir /

I did a mistake, exiecuted "chown root:root *" at root direcotry "/".

The result is: the system can not list the logic volumns. And when I execute vgdisplay, there will be such error message:
vgdisplay: /etc/lvmconf//lvm_lock: Permission denied

OS: HP-UX 11.11

Does anyone know how to fix this mistake.
Thanks very much!!
7 REPLIES 7
Hasan  Atasoy
Honored Contributor

Re: How to fix the mistake "chown root *" at root dir /

hi meiujan ;

if you can execute swverify , you can

swverify -F \* and looking swverify log at the /var/adm/sw , you can fix the problems.
Dennis Handly
Acclaimed Contributor

Re: How to fix the mistake "chown root *" at root dir /

I assume you didn't use the -R (recursive) option? Without -R, should mean relatively few files were broken.

>Hasan: swverify -F \*

The -F option should fix the ownership. But it wouldn't hurt to see what was fixed in the logs.
James R. Ferguson
Acclaimed Contributor

Re: How to fix the mistake "chown root *" at root dir /

Hi:

Are you telling the whole story? If I change the ownership of '/usr/sbin/vgdisplay' from "root:sys" to "root:root" it still works for me on 11.11.

While 'swverify -F \*' will repair ownership *and* permissions on files represented in the IPD (Installed Product Database) recorded by the SD utilities (e.g. 'swinstall'), a recursive 'chown' from '/' may have damaged far more files and directories than 'swverify' will repair. You will need to do a server-wide analysis of your files and directories!

Regards!

...JRF...
Bill Hassell
Honored Contributor

Re: How to fix the mistake "chown root *" at root dir /

This is the very reason that root's HOME should never, ever be /. It's too late now, but change all your Unix servers (HP-UX, Linux, Sun, AIX, etc) so that $HOME for root is another directory. The two most common locations are /root and /home/root. Both locations will minimize the damage from the 3 most dangerous commands:

chown -R *
chmod -R *
rm -r *

The / directory is a very dangerous location -- always perform tasks from a safe directory and test dangerous commands using echo first:

echo chown root:root *

The * character itself can produce unexpected results as the shell replaces the * with matching filenames (assuming that the shell's standard filename expansion +f has been turned on). The above echo command reports what the shell will do to the * character. Remove the special meaning for * and you will see:

echo "*"
*


Bill Hassell, sysadmin
James R. Ferguson
Acclaimed Contributor

Re: How to fix the mistake "chown root *" at root dir /

Hi (again):

Bill's point is very well-taken:

> "...change all your Unix servers (HP-UX, Linux, Sun, AIX, etc) so that $HOME for root is another directory. The two most common locations are /root and /home/root."

My personal preference is to create a directory named '/root' as the ${HOME} for the root user. This is NOT created as a mountpoint. Rather, as a mere directory of '/' the '/root' directory can house a the root's profile and a few other key files and be immediately available in single-user mode.

In contrast, '/home/root' would be subordinate to the '/home' mountpoint and would require that '/home' be mounted in single-user mode to access its contents.

Regards!

...JRF...
meijuan.ding
New Member

Re: How to fix the mistake "chown root *" at root dir /

Hello,
Just tried Hasan's tip. And it works!!
:)
Thanks very much!
Andrew Cowan
Honored Contributor

Re: How to fix the mistake "chown root *" at root dir /

One other point regarding the location of root's home directory. I agree with James that having the directory on a mountpoint such as home means that the files are not available in single-user, however if you are generating large log files in your home directory, they can fill the root filesystem, which will cause far greater problems.