Repairing Accidental Damage to file system permissions and ownership

There are cases when you might accidently change the system permissions and you want to revert it back to default permissions. You can revert ownership and permissions on installed packages by using rpm or you can copy permissions from a clone machine if you have one.

Copying permissions and resetting from a clone machine :

Export the permissions from a good machine :

find / /usr /home -xdev | xargs getfacl -P > /tmp/goodPermissions

Now copy that file and  Import on the damaged machine

setfacl --restore=/tmp/goodPermissions

 

Reset Permissions using RPM

rpm --setperms –a

Or To reset for a single package :

rpm --setperms <packagename>

 

To reset the ownership :

rpm --setugids –a 

or to reset ownership on single package :

rpm --setugids <packagename>