3

I've made today the greatest error on my server using root user:

chown -R 33:33 /

instead of chown -R 33:33 . within some webroot folder.

Well, this brought ssh down. I made it this far to get it working again, so far apache, mysql and php are still working, but I don't know if I ever restart them, or if the server will fail upon restarting.

Is there any "index" or package which will enable reverting these permission to the right / previous ones?

Here is the console output which help me realize and abort that operation:

chown errors

Can I do anything to recover?

chaos
  • 48,171
Jack
  • 33
  • What distribution? – Chris Davies Sep 25 '15 at 10:57
  • here is an example how to deal with this, but none of the solutions will be a 100% reliable and production ready: http://superuser.com/questions/132891/how-to-reset-folder-permissions-to-their-default-in-ubuntu – user1403360 Sep 25 '15 at 11:01
  • Well that's a debian7 having some AMI image ( setup into aws ), so I basically have a 6 month old backup for it, all /var/www rsynced && gitted, so it isn't a big problem for me yet .. having added www-data group for root user .. things are basically working. This accident is yet a big test for me to clone the previous setup into another instance. – Jack Sep 25 '15 at 13:57

1 Answers1

10

No, no chance. You have to reinstall the system.

There are lists in the internet, how to re-chown (or chmod) the filesystem, but you can never cover all files. Those are attempt to solve this without reinstalling. But, I'm sorry for the bad news; The only correct solution is reinstalling, even if you aborted the command after a while.

The system may not even boot anymore. Most of the services probably don't start anymore.


I think, every system administrator had to learn that the hard way. That's why I have a some rules for myself:

  1. Always when doing a command with -R, re-read it at least 3 times, before pressing Enter. Then:
  2. Read it again.
  3. Sure?
  4. Press Enter (and keep the fingers crossed).
chaos
  • 48,171
  • 1
    rpm and deb based systems can provide file lists for installed packages, so it should (theoretically) be possible to derive the ownership:group and permissions for each file managed by a package. That's probably >95% of the system files. – Chris Davies Sep 25 '15 at 11:04
  • @roaima I know, but that's not a clean solution, just an attempt. There are file (for example in apaches htdocs), which are in no package. Such files will be overseen by package lists. – chaos Sep 25 '15 at 11:08
  • Agreed. Whichever route the OP takes (reinstall or fix up) it's going to be painful. – Chris Davies Sep 25 '15 at 11:16
  • 2
    provided a backup can be made, a reinstall would be faster than chowning file one by one. – Archemar Sep 25 '15 at 11:30
  • In your rules, you may add: 0. can I make this operation with a less powerful user? and 3. Is my last backup up to date? – Manu H Sep 25 '15 at 15:46