Without the ability to use sudo
your options become limited to essentially 2.
Method #1
You can either put the users into the same Unix group (/etc/group
) so that they're able to access the same files & directories.
Example
$ more /etc/group
somegroup:x:1001:adminuser,nobody
You then need to set the parent directory that contains this file like so:
$ chgrp somegroup parentdir
$ chmod g+rwxs parentdir
This method will force any files or directories created underneath parentdir
to have the group set to somegroup
. This method works fairly well, by in large, but can be a bit fragile if parentdir
's permissions or ownership gets messed up. Also this method doesn't work if files and/or directories are moved into the directory from some other location.
Method #2
The more robust way to do this would be to make use of access control lists (ACLs) on the file or directory of interest, using the command setfacl
.
$ setfacl -Rdm g:somegroup:rx somedir
$ ll -d somedir/
drwxrwxr-x+ 2 saml saml 4096 Feb 17 20:46 somedir/
You can then confirm that the ACL has been applied using getfacl
.
$ getfacl somedir/
# file: somedir/
# owner: saml
# group: saml
user::rwx
group::rwx
other::r-x
default:user::rwx
default:group::rwx
default:group:somegroup:r-x
default:mask::rwx
default:other::r-x
Setting the permissions above on the parent directory will enforce that a default ACL will get applied to any new files or sub-directories contained within somedir
.
References