Skip to content

Instantly share code, notes, and snippets.

@shoaibi
Created June 25, 2015 20:54
Show Gist options
  • Save shoaibi/ac894433e774999d7e52 to your computer and use it in GitHub Desktop.
Save shoaibi/ac894433e774999d7e52 to your computer and use it in GitHub Desktop.
A handy script to generate permissions(modes, user and group) restore scripts for /etc directory.
#!/bin/bash
# At the start of my DevOps career I used to mess up /etc permissions
# a lot so I ended up creating 2 set of scripts that would be generated
# on nightly bases using cron and then when required I'd just execute
# these scripts
find /etc -exec stat --format "chmod %a %n" {} \; > /root/restoreperms.sh
find /etc -exec stat --format 'chown %U:%G %n' {} \; > /root/restoreowners.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment