Last active
March 15, 2018 15:19
-
-
Save daks/9322644 to your computer and use it in GitHub Desktop.
restore permissions and user/group on Linux/Unix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sometimes, when changing permission or ownership you run a command like | |
# chown -R www-data: .* | |
# and it does what you want correctly: change ownership on dotfiles | |
# but it does also what you don't want: change ownership on all files which are in the parent directory | |
# which is really bad | |
# the solution, taken from http://sysadminnotebook.blogspot.fr/2012/06/how-to-reset-folder-permissions-to.html | |
# 1. on a snapshot or another Debian installation run | |
find / -exec stat --format "chmod %a %n" {} \; > /tmp/restoreperms.sh | |
find / -exec stat --format 'chown %U:%G %n' {} \; >> /tmp/restoreperms.sh | |
# 2. on your screwed installation run | |
sh /tmp/restoreperms.sh | |
# other solutions consist on using information about packages (for Debian) but I haven't tested it | |
# and the solution to change permissions/ownership on dotfiles is to run (see http://blog.matoski.com/articles/debian-restore-var-ownership-permissions/) | |
chown -R /var/www/.[^.]* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment