ACL (Access Control Lists) would be easiest.
For Ubuntu:
##Install acl:
sudo apt-get install acl -y
Next, we need to set up the mount to handle it. If you’re running Ubuntu >= 14.04, you can ignore this next bit:
Configure fstab
edit /etc/fstab. It will look something like this:
UUID=b96601ba-7d51-4c5f-bfe2-63815708aabd / ext4 noatime,errors=remount-ro 0 1
After noatime, add “,acl” so it looks like this:
UUID=b96601ba-7d51-4c5f-bfe2-63815708aabd / ext4 noatime,acl,errors=remount-ro 0 1
Next, run this so the change takes effect:
mount -o remount /
Now, let’s check that it’s working:
mount |grep acl
You should see something like this:
/dev/vda1 on / type ext4 (rw,noatime,acl,errors=remount-ro)
If you don’t, let me know.
Configuring the ACL
Now, on to setting the ACL (changing the path to the path you need, and MyLogin to your actual login):
sudo setfacl -m u:MyLogin:rwx /var/www/
Now, let’s see if that worked:
sudo getfacl /var/www/
If it worked, it will look something like this:
# file: /var/www/
# owner: www-data
# group: www-data
user::rwx
user:MyLogin:rwx
group::r-x
mask::rwx
other::r-x
As you can see, you now have full permissions.
Differences for CentOS/Fedora
to install acl, run this:
yum -y install acl
to edit /etc/fstab, the line needed changing will look like this:
LABEL=DOROOT / ext4 errors=remount-ro 0 1
Change it to look like this:
LABEL=DOROOT / ext4 acl,errors=remount-ro 0 1
All other things will be the same.