How to revert chown command?

How easy is to mess up a system with sudo!

From http://unix.stackexchange.com/questions/48845/how-to-revert-chown-command

Rpm based distros help a little. I have to check in deb and apt offer something comparable

If I run:

sudo chown -R user:user /

Can I revert it to what it was before I ran it?

After sudo chown -R user:user /, it’s likely that the system is so badly hosed that you can’t restore from a backup. – Keith ThompsonSep 22 ’12 at 23:59

If your distro is RPM based, you can restore ONLY files that installed by rpm packages.

To restore all package permissions:

rpm --setperms -a

To restore all package owner (user/group):

rpm --setugids -a

If -a doesn’t run, you can execute a bash loop:

For permissions:

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

For owner:

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

Extracted from: http://www.sysadmit.com/2016/10/linux-restaurar-permisos-de-un-paquete.html

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.