Backup and restore permissions linux (accidental chmod -R)

โ€”

by

in ,
cd /etc/
chmod -R 664 .

*SHIT!*

If you find you did an accidental chmod -R, you may be able to restore it.

  1. Make sure SSH login keeps working (chmod -R 0600 /etc/ssh )
  2. Install a similar machine
  3. On that machine, issue this command:
    find /etc/ -exec stat --format "[ ! -L \"{}\" ] && chmod %a \"%n\"" {} \; >chmod_fixer.sh
    
  4. Copy that file to the f*cked up box
  5. Chmod +x chmodder.sh
  6. Execute chmodder

You might want to install the software on the chmod-sourcebox to make sure the two boxes look alike.