Give user access to folder without changing ownership?

I have a script that works with /etc/NetworkManager:

drwxr-xr-x   6 root root    4096 Apr  3  2017 NetworkManager/

I want to give the user programX write permission for this folder without changing the ownership.

Is that possible or would I have to change the ownership?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

This is what access control lists are for.

setfacl -m 'u:programX:rwx' /etc/NetworkManager

The user account programX now has read, write, and traverse access to the directory, but does not have ownership access.

Bonus way of doing this on FreeBSD with its NFS ACLs:

setfacl -m 'u:programX:rwxD::allow' /etc/NetworkManager

Further reading

Method 2

You can use ACLs for this, first of make sure that the acl package is installed.

After that you can run

setfacl -m u:programX:rw NetworkManager/


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments