Skip to content

Instantly share code, notes, and snippets.

@muratgozel
Last active November 2, 2020 09:37
Show Gist options
  • Save muratgozel/e260aadd5695e802f23ca6510a972e74 to your computer and use it in GitHub Desktop.
Save muratgozel/e260aadd5695e802f23ca6510a972e74 to your computer and use it in GitHub Desktop.
Configure existing and future file and folder user and group permissions recursively in linux.
#!/bin/bash
SAMPLE_DIR=/mnt/some-volume
# change ownership of the directory and all of its contents
chown -R cmsman:cmsteam $SAMPLE_DIR
# change permissions of the directory and all of its contents
chmod -R u=rwX,g=rwX,o-rwx $SAMPLE_DIR
# set uid and gid
chmod -R u+s $SAMPLE_DIR
chmod -R g+s $SAMPLE_DIR
# set acl for the folder and all of its contents
setfacl -R -m user:www-data:rwx $SAMPLE_DIR
setfacl -R -m user:cmsman:rwx -m group:cmsteam:rwx $SAMPLE_DIR
setfacl -R -m default:user:cmsman:rwx -m default:group:cmsteam:rwx $SAMPLE_DIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment