Restore default ownership in CentOS after terrible chown
"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.