Restore default system file & folder permission on Linux : using -setperms and --setugids

We can recover or restore the default file / folder permission and ownership using rpm command with the options -setperms and --setugids.  

This will help system admin to recover file permissions in easy way. But the below command will take time to change the permission for entire system files and directories. But you have to tolerate ....

This is very useful option which i found in RPM command.

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

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

2) To permissions on files and directories

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

Post a Comment


  1. Great post!!

    You can also use -a parameter:

    To restore all package permissions:

    rpm --setperms -a

    To restore all package owner (user/group):

    rpm --setugids -a

    Extracted from: