Accidentally ran "chown -R ubuntu:ubuntu /", how to repair?

2

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.

Thanks.

Steven L

Posted 2013-05-28T15:41:58.927

Reputation:

1Please don't try chmod -R a-x /. – devnull – 2013-05-28T15:58:55.127

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 – 2013-05-30T08:17:18.110

Answers

3

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!

Chris

Posted 2013-05-28T15:41:58.927

Reputation: 1 766