Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

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

1 Answer 1

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!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.