Score:0

Restore permissions to all files in folder using RPM

ru flag

Using chmod, I accidentally changed everything in a bin folder and now sudo/su doesn't work.

I know rpm -q --whatprovides can provide which RPM provides a specific file. and rpm --setperms can restore everything provided by a RPM.

Is there a way to restore the permissions of all the files in a folder using rpm?

Score:2
jp flag
rsc

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.