Reset the File Permissions on a Fedora Machine

Written by James McDonald

August 14, 2011

Just recently I discovered a problem caused by a trial software install. Files in /usr had been changed to be owned by someone other than root. (postgres).

I did try to fix the problem by running chmod root:root /usr -R

But I’m not confident that everything is now correctly owned.

Because it’s an RPM packaged system I can use rpm to help with resetting ownership (–setugids) and permissions (–setperms) as follows:

rpm -qa | xargs -IFILE rpm --setugids --setperms FILE

The command basically says query the rpm database (-q) for all installed packages (-a) pipe the list of packages to xargs and run rpm with the –setugids and –setperms flags set on each package to fix up it’s perms.

If you run the above you will see alot of “No such file or directory” messages.

Note: Do the above at your own risk.


Submit a Comment

Your email address will not be published.

You May Also Like…

PHP Iterators

Just came across a Youtube talk "Iterators in PHP" by Jake Smith published in 2014 that steps through the many...

PHP array_map Multiple Arrays

array_map can take multiple arrays. I like how it starts mapping through them starting at the first element of each...