Restore System Default Permissions using Single Command

Share It!

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.

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.