2

I know they say that given root access, someone will eventually type before they think and fubar their machine, and I just did.

I did a recursive chmod changing everything to 775 thinking I was in a sub directory, but alas, I was in /. Is there any magical way to undo this, or at the very least, get a list of default directory permissions and manually restore them?

DWilliams
  • 953
  • 2
  • 20
  • 29
  • See http://serverfault.com/questions/40025/how-do-i-recover-a-rhel-4-3-server-from-bad-permissions-set-over-the-entire-files – Evan Anderson Sep 02 '09 at 14:24
  • 1
    The "real" way is to restore from backup. Assuming you don't have backups, have a look at that question-- there are some ideas that can get you most of the way there, depending on what distro you're running, etc. – Evan Anderson Sep 02 '09 at 14:25

4 Answers4

4

I have exact same problem.

rpm -a --setperms

fixed the problem.

3

If your distribution is rpm based, the rpm database contains permission information. The command

rpm --setperms {packagename}

should reset the permission for the given package.

hlovdal
  • 1,115
  • 11
  • 18
  • 1
    you can simply do : rpm -a --setperms on rpm based distros in order to restore most of permissions (run it as root) – Razique Sep 03 '09 at 07:17
1

There's no undo. Beyond installing a box with similar unix, and scripting something to check everything permissions, I don't believe there's a list of default permissions either. Not very helpful, unfortunately.

Cian
  • 5,838
  • 1
  • 28
  • 40
  • Accepting this answer because, well, "There's no undo". I just re-installed the server (all important files were backed up but not generic system files and such). The other RPM-based solutions presented sound nice but this is Debian =/ – DWilliams Sep 03 '09 at 23:11
0

To amend the "rpm --setperms" information, that will allow you to fix the permissions of all files and directories which were installed as RPM packages. It will NOT fix the permissions of files that were installed without using RPM.

You can get a list of all the installed packages by doing "rpm -qa", for use in feeding to the "rpm --setperms". You can also use "rpm -Va | less" to have RPM do an integrity check on all installed files and directories to allow you to do more fine-grained adjusting of permissions -- it will report if the file contents, modes, and times have changed, and whether the file is a configuration file or not.

Sean

Sean Reifschneider
  • 10,720
  • 3
  • 25
  • 28