Linux Chown Command – Accidentally Ran ‘chown www-data:www-data / -R’ as Root

chownlinuxrootUbuntu

I just ran this a few seconds ago. I managed to do CtrlC as soon as I realized what I started doing.

So far the only directory it's started going through is /bin.

I'm afraid to do anything else. So far I realized I can't use su as my normal user anymore.

Luckily I still have another root terminal open. What do I do?

Best Answer

Most everything in /bin/ should be owned by root:root, so if you run the following you can fix the ownership on those files:

chown root:root -R /bin/ 

You may also want to make sure the setuid bit is properly set on /bin/su, which you can fix with the following:

chmod 4755 /bin/su