Restore file ownership and permissions in RPM based Linux distributions

If you have messed up the file permissions and ownerships of installed packages on your Linux box for any reason, you can fix these for all the packages that were installed by rpm. This method will only work for RedHat, CentOS, Fedora and other rpm based Linux distribution.

This will restore ownerships and then restore permissions for all installed packages

for p in $(rpm -qa); do rpm --setugids $p; done
for p in $(rpm -qa); do rpm --setperms $p; done

Leave a Reply

Your email address will not be published. Required fields are marked *