Adding user to ownership in addition to another user
Solution 1:
According to the traditional file permission that's not possible: a file has only a single owner.
Your approach including admin to apache group should work.
However most modern filesystems support ACLs. If you want to use ACLs to give another user read (r
) and write (w
) permissions then you can use the command setfacl:
setfacl -m user:admin:rw /path/to/webserver/www
Even if the filesystem you are using supports ACLs, check that it is mounted with support for ACLs. In that case you need to issue the command mount
and get the dev related to the filesystem, for example:
[root@centos]#mount
/dev/sda3 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
The dev for the root filesystem is /dev/sda3
.
Now with the command tune2fs
you have to issue the command:
[root@centos]tune2fs -l /dev/sda3 | grep acl
Default mount options: user_xattr acl
In this case it has acl
enabled. If it wasn't the case then you have to modify /etc/fstab to include acl
on the options as it is explained here.