Skip to content

Instantly share code, notes, and snippets.

@chryss
Last active December 18, 2015 03:09
Show Gist options
  • Save chryss/5716135 to your computer and use it in GitHub Desktop.
Save chryss/5716135 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Fixing permissions for group members. System default is UMASK 077 or 022,
# which makes file invisible to members of the group.
#
# This script recursively sets:
# * all directories under the given directory to 775
# * all files under the given directory to 664
# That is, the owner and group members have full rwx permissions,
# and others can access all directories and read, but not write/delete files.
#
# Potential pitfalls:
# * Files from a certain list of extensions will be set to user and group executable (774)
# This is not necessarily the desired behaviour. Other previously executable files
# may have to be reset manually
#
# Chris Waigl, chris.waigl AT gmail.com
#
# CHANGELOG:
# 2013-06-02 - CW - Initial creation
if [ -z $1 ] || [ -f $1 ]; then
echo "Argument missing or not a directory. Usage: $0 <directory>"
exit 1
fi
if [ $# -ge 2 ]; then
echo "Too many arguments. Ignoring any but the first."
fi
find $1 -type d -exec chmod 775 {} \;
find $1 -type f -exec chmod 664 {} \;
find $1 -type f \( -iname "*.py" -o -iname "*.pl" -o -iname "*.ncl" -o -iname "*.sh" \) -exec chmod 774 {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment