Restore System Default Permissions using Single Command

I recently came across a system which had a few directories set to 777(recursively), the sysadmin expected to install an application and changed all the permission a mess, I didn’t know where to begin, I found one rpm has a parameter called –setperms and –setugids. It is most helpful stuff when you face above situation. To run following commands you need to have a sudo access either root access. In this article we will explain how to restore system default permissions using single command.

Restore System Default Permissions

1# To reset uids and gids on files and directories :

# for u in $(rpm -qa); do rpm --setugids $u; done

2# To permissions on files and directories

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

Enjoy it!

Leave a Reply

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.