-1

I mistakenly ran chown -R admin / on Centos 6

Is there any command to change user to match group? I think this should be a fix since by default user=group?

P.S. An OS reinstall can fix this, but I am looking for alternate solutions to avoid this.

nkshio
  • 1,060
  • 1
  • 14
  • 23

1 Answers1

1

Well, "admin" isn't a standard user, guess you added it or you wouldn't have such an issue. If that command really worked I guess the first issue may be to login as root but assuming you can at lest get to the state that you can do that you have a few options (besides restore from backup or rebuild). You can use rpm to restore owner/permission of any file handled by rpm.

rpm --setugids coreutils

or to do all of it at once (which I strongly discourage you from doing)

rpm --setugids $(rpm -qa)

dunno what the impact would be of that since when I did a quick test in lab it gave me a ton of "file not found" errors.

As for your original question, haven't seen any "user=group" option but you could do something like

find /home -user admin ! -group admin|while read i;do echo chown --no-dereference $(stat -c %g "$i") "$i";done

and if that looks good run it without "echo"

find /home -user admin ! -group admin|while read i;do chown --no-dereference $(stat -c %g "$i") "$i";done
lpaseen
  • 1,189
  • 8
  • 8