You can use ACLs to grant permission for files in your home directory to another user. And the command to set ACL is setfacl
.
Say the accounts you control are john and smith. Now, if want smith to have full access to files john's home directory, then he can run the setfacl
command as john with these options:
setfacl -R -m u:smith:rwx /home/john
The above setfacl
command will provide the user smith full access to the home directory of john . This command has to be executed by the owner of the directory to whom the access is being opened to (john in this case) or root .
You can modify the permissions or the directory name or tell the setfacl
command whether the access has to be given to a user or a group. For example:
setfacl -m u:smith:rx /home/john
The above command will give the user smith only read-only access to /home/john.
[sreeraj@server ~]$ setfacl -m u:soum:rwx /home/sreeraj
On the same server:
[soum@server ~]$ cd /home/sreeraj
[soum@server sreeraj]$ touch file_by_soum
[soum@server sreeraj]$ ll file_by_soum
-rw-rw-r-- 1 soum soum 0 फ़रवरी 16 16:27 file_by_soum
[soum@server sreeraj]$
From the man page of setfacl
:
EXAMPLES
Granting an additional user read access
setfacl -m u:lisa:r file
Revoking write access from all groups and all named users (using the effective rights mask)
setfacl -m m::rx file
Removing a named group entry from a file's ACL
setfacl -x g:staff file
Copying the ACL of one file to another
getfacl file1 | setfacl --set-file=- file2
Copying the access ACL into the Default ACL
getfacl --access dir | setfacl -d -M- dir
setresuid
system call it is then possible to chose between all the different ways the two uid can be mixed. Alas it appears that on the Linux system where I am testing, none of the combinations will allow me to perform thechown
system call. – kasperd Feb 16 '15 at 17:48