Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

marked as duplicate by Kyle Brandt, MikeyB, Zypher, Chopper3, pQd May 16 '10 at 12:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2  
This one has been asked a bunch, kind of disconcerting actually :-) –  Kyle Brandt May 14 '10 at 15:58
2  
Hopefully you have good backups of your production machines. So if something like this does happen all you have to do is restore. –  Zoredache May 14 '10 at 16:31

4 Answers 4

up vote 7 down vote accepted

"Just reinstall and be happy it wasn't a production machine?"

Yes.

share|improve this answer
rpm -a --setugids
share|improve this answer

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.

share|improve this answer

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 -P > /tmp/permissions_from_server1

server2:# setfacl --restore=/tmp/permissions_from_server1

YMMV, here's a starting point.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.