I accidentally ran "chown -R ubuntu:ubuntu /" on a cluster of 10 servers. I've since managed to repair the majority of the filesystem by initially editing /etc/rc.local, placing a lot of chown commands in there, and rebooting.

At this time the systems appear to be working correctly, but I wanted to be sure I've fixed everything.

In order to identify the proper permissions, I booted up a fresh system with the same software installed, and looked up all files not owned by user:root, not owned by group:root, as well as all SUID and GUID bits.

Specifically, I ran these commands:

  1. while read line; do user=$(echo $line |cut -d ":" -f 1); if [ $user != "root" ]; then echo ------${user}------; find / -user $user 2> /dev/null; fi; done < /etc/passwd

  2. while read line; do user=$(echo $line |cut -d ":" -f 1); if [ $user != "root" ]; then echo ------${user}------; find / -group $user 2> /dev/null; fi; done < /etc/group

  3. find / -perm -1000
    find / -perm -2000
    find / -perm -3000
    find / -perm -4000
    find / -perm -5000
    find / -perm -6000
    find / -perm -7000

And then manually made these changes to the affected systems.

My question is, did I miss anything, and are these systems now as good as a freshly installed system?

This is on Ubuntu 12.04.2 LTS.


migrated from stackoverflow.com May 28 '13 at 16:49

This question came from our site for professional and enthusiast programmers.

  • 1
    Please don't try chmod -R a-x /. – devnull May 28 '13 at 15:58
  • In my opinion your recovery procedure looks good. I'ld additionally check which files are on your system that are not on the freshly installed system. These are the files that you missed and that might require a change. – Werner Henze May 30 '13 at 8:17

You have few choices here:

  1. Restore from backup.
  2. If no backup, then take files you need into safe location (USB/network storage) and perform reinstall.

Anything else will be just a waste of your time. Yes, you can possibly restore permissions but trust me - this will take way too long! Reinstall, be careful in the future.

With command like that I always advise to use full path!

You might have issues with ssh, mta etc. Some log files might not work correctly. There are some commands which require special permissions. Too much really to be sure!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy