Folder Access – How to Give User Access Without Changing Ownership

filespermissions

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?

Best Answer

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

Related Question