Restore permissions to all files in folder using RPM

Solution 1:

I'm afraid the built-in features don't apply per directory. However the following might be a solution…let's assume you messed up /usr/bin permissions recursively, the following might help:

rpm --setperms $(rpm -qf $(find /usr/bin) | sort -u)

It looks up all elements below /usr/bin and queries the RPM database for the corresponding package, deduplicates the RPM packages list and runs rpm --setperms for each applicable RPM package.