How to grant permission to other user with setfacl

The tool setfacl on linux is used to set file access control lists, for example, I have a user named stephen , and I have a test file…

How to grant permission to other user with setfacl

The tool setfacl on linux is used to set file access control lists, for example, I have a user named stephen , and I have a test file owned by root, I can use setfacl to grant access to the user like below:setfacl -m u:stephen:rw test

To get the file access control list use the command getfacl , we can just pass the file name to the command like below:getfacl test

In practice

I wll use /etc/hosts as an example, the file access control list for the file is like below:$ getfacl /etc/hosts
getfacl: Removing leading '/' from absolute path names
# file: etc/hosts
# owner: root
# group: root
user::rw-
group::r--
other::r--

If I open the file with stephen account, the file is readonly, and I can grant rw permission to stephen with the following command:$ setfacl -m u:stephen:rw /etc/hosts$ getfacl /etc/hosts
getfacl: Removing leading '/' from absolute path names
# file: etc/hosts
# owner: root
# group: root
user::rw-
user:stephen:rw-
group::r--
mask::rw-
other::r--