Restore System Default Permissions using Single Command
By Anuket Jain On 31 October 2015 In Linux
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.
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