Sunday, January 24, 2016

Recursive file permissions issue on / directory

One developer had run "sudo chown -R user ../../" from his home directory and created permission issues at / in one of the systems. Most of the directories at "/" level are with "user:root" permissions and it looks all bad. System has stopped responding to ssh connections. It says "connections refused" to new ssh connections. 

Solution:

This is a very bad condition but yes, we can recover it using the rpm database. Run the command as follows?

# for i in $(rpm -qa); do echo "Working on $i"; rpm --setugids $i; rpm --setperms $i; done

This will restore the user ownership, group ownership as well as set the permissions too. This will display lots and lots of messages on screen, as well as the errors, you can just ignore them out. And it will take much time to restore the permissions/ownership depending on the number of installed rpms.

Please note that only those file/directory permissions/ownership will be changed back to normal which are deployed by rpm. Other file permissions/ownerships won't be changed at all.


No comments:

Post a Comment