When you add new users they are usually assigned to a new group with the same name, a fine thing with this is that you can add two users to the same group or user A to the group of user B and then share read and write permissions on a directory without the ability for others to access the same directory. First of all check which groups your users belongs to:
groups <username>
This will output something like:
www-data : www-data
For your web server user. Now let's make a new group called webmasters:
sudo groupadd webmasters
Then we assign our users to this new group:
sudo adduser www-data webmasters
sudo adduser rabbit webmasters
Verify that it worked using the group list command above, after that you need to reboot to make sure that all new group assignments and permissions are up to date by forcing all users to login again:
sudo reboot
Now let's configure the permissions, set the ownership of your www folder to www-data and webmasters:
sudo chown -R www-data:webmasters /var/www
Then change the permissions to 770:
sudo chmod -R 770 /var/www
This will grant +rwx
permissions for user www-data and +rwx
permissions for group webmasters where your user rabbit is a member. Any user in the group webmasters will now have +rwx
permissions for the folder /var/www
.
The last 0
in 770
means no permissions -rwx
and applies to all other users on your server.