Fix a lot of rights

A customer called and wanted help with an error they made.

The error was simple, they typed:

chmod -R 660 /

and now things broke. Of course things broke. If they would not brake that would be very weird.

Luckily they had a second server and a simple one-liner stole all the rights from this second server and and we could put these on the broken one.

The oneliner

find / -depth -printf 'chmod %m\t\t-- "%p"\nchown %u:%g\t-- "%p"\n' >

produces output like this

chmod 644		-- "/etc/sysconfig/kdump"
chown root:root	-- "/etc/sysconfig/kdump"
chmod 644		-- "/etc/sysconfig/rhn/sources"
chown root:root	-- "/etc/sysconfig/rhn/sources"
chmod 644		-- "/etc/sysconfig/rhn/sources.rpmforge.txt"
chown root:root	-- "/etc/sysconfig/rhn/sources.rpmforge.txt"

Running this script on the broken server left us with something that was working.


dpkg -x <package name>

on all cached packages in /var/cache and after that a

dpkg --reconfigure -a

Solved the rest.

Pheeeuuwww, we were lucky :-)

See also