Restore default ownership in CentOS after terrible chown [duplicate]
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.
rpm -a --setugids
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:
server1:# find / /usr /home -xdev | xargs getfacl -Pp > /tmp/permissions_from_server1
server2:# setfacl --restore=/tmp/permissions_from_server1
-
-xdev
tells find to stay on one filesystem. - The upper-case
-P
stands for Physical walk; i.e.: ignore symlinks. - The lower-case
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.