Access Control Lists
OR
Default Permissions
This is a how-to specifically for ‘ACL’s or ‘Access Control Lists’. These dictate the default Username, Groupname, and/or permissions that apply to the top directory and back down, as you so choose. This is awesome for when you mount secondary hard drives, or will be using a directory as a shared folder and need unified permissions beyond the built-in simple linux permissions.
tl;dr
sudo setfacl -Rdm u:usernamehere:rwx /path/to/file
sudo setfacl -Rm u:usernamehere:rwx /path/to/file
sudo setfacl -Rdm g:groupnamehere:rwx /path/to/file
sudo setfacl -Rm g:groupnamehere:rwx /path/to/file
setfacl is to set the acl.
-R is for recursively acting on all files from /path/to/dir
down
d is for default, setting the defaults first time round
m is for “modifying” the acl
Setting the default
flag first changes the default behavior of new files or directories to be created below the directory you’re modifying.
sudo setfacl -Rdm u:usernamehere:rwx /path/to/file
sudo setfacl -Rdm g:groupnamehere:rwx /path/to/file
Then, to make sure all files, recursively, receive the update, run it again without the d
option in the command flag.
sudo setfacl -Rm u:usernamehere:rwx /path/to/file
sudo setfacl -Rm g:groupnamehere:rwx /path/to/file
And to read the ACL, you simply use getfacl /path/to/file
.