4

I accidentally ran "chmod 775 -R /" instead of "chmod 775 -R ./" and changed the permissions for everything and now the server is broke.

Anyone know how I can quickly fix this???

  • http://serverfault.com/questions/233764/revert-chmod-777-r – ooshro Mar 01 '11 at 15:17
  • What distro are you using? There are a lot of similar questions: [How to repair/restore ubuntu 10.04 after 'sudo chmod / 777'](http://serverfault.com/q/221447/51929), [chmod -R 777 / on ubuntu - numerous problems](http://serverfault.com/q/141806/51929), ... – Lekensteyn Mar 01 '11 at 15:21
  • I'm afraid there is no quickly for this fix. Look at the link provided by ooshro to find ways to reset permissions for packages. As for the data on the system, that will probably have to be changed by hand. – cledoux Mar 01 '11 at 15:27
  • its redhat. aargh – Grant Unwin Mar 01 '11 at 15:50
  • kernel 2.6.18-164.2.1.e15 – Grant Unwin Mar 01 '11 at 15:50

4 Answers4

11

If this is a RPM based distribution, you can use the following command to reset permissions to the RPM defaults:

rpm --setperms $(rpm -qa)

It'll at least get you started on the path.

Doug
  • 646
  • 3
  • 8
2

You have backups, right? Hopefully ones that include both files and filesystem metadata? If this happened in my environment, I'd pull last night's backup down to fresh disks and get booted on that. Hope it works out for you!

Jeff Albert
  • 1,967
  • 9
  • 14
1

This isn't a lot of help if you didn't know about it or use it before, but you can backup permissions in a restorable way. See Backing up permissions on Linux

dunxd
  • 9,482
  • 21
  • 80
  • 117
0

Ran into this myself. Basically what you could do is to install the same version of the OS or better yet, if you have another system installed with the same OS and it's still intact, do an ls -al inventory of all the files then run it through a script to change them back to the same permissions. You could use associative arrays to do this with by storing the known permissions then rereading them to set it on the effected host.

This post has a script to do just that with some code to go along with it: Permission Problems and accidentally running chmod 0:

slm
  • 7,355
  • 16
  • 54
  • 72
xBlender
  • 1
  • 2