Issue
I want to give one particular user read access to a file on a unix machine. I am not root so I guess I can not do chown
.
I tried searching for something that uses chmod
, but there it looks like I can't specify a particular user, only a one-self, group, or all.
I guess this was asked before already, but I couldn't find anything.
Solution
Generally when you want more fine-grained permissions in Linux, you should use Access Control Lists. The Arch Wiki has a good guide on how to set it up.
Once set up, you can define more complex rules for modifying the access control policies for your mounted filesystem.
You can set these rules with commands that look like: setfacl -m "u:johny:r-x" abc
.
This says "Give (user) Johny read and execute permissions to the file/directory specified by the path abc
".
You would then also be able to see the permissions for a filesystem object using getfacl
root@testvm:/var/tmp# getfacl appdir/
# file: appdir/
# owner: root
# group: appgroup
user::rwx
group::rwx
group:testusers:r--
mask::rwx
other::r-x
In this example you can see the default for any user/group which is not (in) the testusers
group, can read, write, or execute the directory. But testusers
can only read.
Answered By - Edward Minnix Answer Checked By - Robin (WPSolving Admin)