UPDATED: Repair process below
Want to change the ownership of all files in a directory to a user named ‘foo’? Think this is a good way to do it?
chown -R foo * .*
Yeah, don’t do that. In one of those awesomely awful “D’oh” moments, I did that. Remember: “.*” matches “..”. So that will traverse up one level, and then recursively back down.
And of course …. I ran this in /mnt . It took me about 5 seconds to realize what I had just done, before hitting ^c. Yeah, my system is b0rked. 🙁
Resolution provided by Simon Sekidde at Red Hat:
On Red Hat Enterprise Linux (and derivatives), there is an easy way to re-initialize the ownership and permissions of RPM-installed files:
for i in `rpm -qa`; do rpm --setugids $i; rpm --setperms $i; done
Make sure to use –setugids before –setperms; if the order is reversed, changing the ownership with –setugids will reset any suid/sgid bits set by –setperms.
Behold… the power of UNIX!!!