Skip to content

Instantly share code, notes, and snippets.

@dev01d
Last active November 9, 2023 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dev01d/4cf9c727cae3b2a90f9779ffc4135b1d to your computer and use it in GitHub Desktop.
Save dev01d/4cf9c727cae3b2a90f9779ffc4135b1d to your computer and use it in GitHub Desktop.
Fix all directory and file permissions (even dot files).
#!/usr/bin/env bash
#
##
### Fix file pemissions
### dirs 755 files 644
##
#
CWD="$(pwd)"
echo -e "\e[1;25;33m\nFixes file and dir perms in current working directory\e[0m\n"
read -p "Include hidden files (Y/n)? " answer
case ${answer:-y} in
y|* )
echo -e "\e[1;25;32m\nFixing Files (755)\e[0m"
find $CWD -type d -exec chmod 755 {} \;
echo -e "\e[1;25;32mFixing Files (644)\e[0m"
find $CWD -type f -exec chmod 644 {} \;
;;
n|N )
echo -e "\e[1;25;32m\nFixing Files (755)\e[0m"
find $CWD -not -path '*/.*' -type d -exec chmod 755 {} \;
echo -e "\e[1;25;32mFixing Files (644)\e[0m"
find $CWD -not -path '*/.*' -type f -exec chmod 644 {} \;
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment