Possible Duplicate:
How do I recover a RHEL 4.3 server from bad permissions set over the entire filesystem?
Is there any way to restore the default ownership of a CentOS filesystem after an accidental chown -R user:group /* ?
Before I go and reinstall, I thought I'd ask and perhaps save some time. I'm in the process of setting up a new dev machine (thankfully not prod) and typed too fast or missed the . key or something. I tried to cancel as soon as I caught it but all my /bin /boot /dev etc had already been changed.
Is there hope, or just reinstall and be happy it wasn't a production machine?
"Just reinstall and be happy it wasn't a production machine?"
Yes.
If you happen to have an exact clone of that machine, it is possible to restore permissions using the other machine as a model. Something like:
-xdev
tells find to stay on one filesystem.-P
stands for Physical walk; i.e.: ignore symlinks.p
preserves leading slash. Without this switch,getfacl
's default behavior is to remove the leading slash, causing the restore fail.YMMV, here's a starting point.
Reinstalling is ultimately easier, and is the route I would take. If this were a production server and you didn't have backups, your first task would be regaining root privileges, as
/bin/su
and/usr/bin/sudo
may not work any longer.Log in locally, as root, reset the ownership of those binaries, and start working on the errors you immediately see crop up, such as libraries not working, etc.
From a similar machine, you could build a list of files in various system directories with a shell/Perl/Python script, and then run the script in reverse on the affected system, to grant proper ownerships to the files.
It's not the end of the world, although pretty close, and it's a huge pain in the bum.