[BlueOnyx:21038] Re: User permission change gone wrong ...

Michael Stauber mstauber at blueonyx.it
Mon May 15 01:50:03 -05 2017


Hi Don,

> Full disclosure, it was a fat-finger/ID10T error...
> 
> But I managed to royally foul up permissions server wide. Is there any
> sort of script out there that will get /etc/ /usr/, and so forth back to
> normal. I think I'm getting close.

Yikes. That's indeed pretty bad. :-/

The RPM database is your best bet for a recovery of most things that
were installed via RPM's. Sadly that won't fix permissions/ownerships
for things that were then modified (or created) via the RPM's
post-install scripts. But there is also a cure for that.

Give this a try:

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

Lastly: You might want to reinstall all RPMs to *really* make sure
everything is back in proper order. So here is a one-liner for that purpose:

3.) Reinstall of all RPMs via polling RPM database and then using YUM:

rpm -qa --qf '%{name} ' | xargs yum reinstall -y

The first part polls the RPM database for *all* installed RPMs and
formats the output into a single line that contains just the RPM names
and has each name followed by an intentional space.

We then use xargs to pass this long list of RPMs to reinstall directly
to "yum reinstall -y " (yes, there is a space at the end!) and it will
reinstall every RPM via YUM that can be fetched via YUM. This might not
cover things that came with PKGs, though. Or things which no longer are
available via YUM for one reason or another.

If there are problems with software that came via PKGs: Just uninstall
and reinstall them via the GUI to solve these issues.

All in all: This should get you back onto your feet and this is as good
as it'll get.

-- 
With best regards

Michael Stauber



More information about the Blueonyx mailing list