Created
May 13, 2018 23:44
-
-
Save filipeandre/07a3290ebd32b5084c93543e3398854a to your computer and use it in GitHub Desktop.
Restore home directory permissions
This file contains hidden or 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
| #!/bin/bash | |
| usage(){ | |
| echo "Usage: $0 username" | |
| exit 1 | |
| } | |
| restore(){ | |
| getent passwd $1 | |
| if [ $? -eq 0 ]; then | |
| find /home/$1 -type d -print0 | xargs -0 chmod 0775 | |
| find /home/$1 -type f -print0 | xargs -0 chmod 0664 | |
| echo "Done." | |
| else | |
| echo "User does not exist!" | |
| fi | |
| } | |
| [[ $# -ne 1 ]] && usage | |
| restore $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment