Skip to content

Instantly share code, notes, and snippets.

@cballenar
Last active November 6, 2015 22:09
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 cballenar/56ed5663401aba6d7126 to your computer and use it in GitHub Desktop.
Save cballenar/56ed5663401aba6d7126 to your computer and use it in GitHub Desktop.
Avoid having to manually change the permissions after adding files as root or another user. These commands have to be ran as root. After running these commands the files and directories inside www will inherit the ownership and permission given.
# add user to www-data
gpasswd -a user www-data

# change ownership
chown -R user:www-data /var/www/

# find all files, set permissions to rw-r-----
find /var/www -type f -exec chmod 0640 {} \;

# find all folders, set group id and permissions to rwxrwx---
find /var/www -type d -exec chmod 2770 {} \;

Source: Lekensteyn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment