Skip to content

Instantly share code, notes, and snippets.

@reanim8ed
Created July 20, 2023 16:11
Show Gist options
  • Save reanim8ed/0daa477b6c12bc7c15e1b21f6b1d0b69 to your computer and use it in GitHub Desktop.
Save reanim8ed/0daa477b6c12bc7c15e1b21f6b1d0b69 to your computer and use it in GitHub Desktop.
[Make all new files in a directory accessible to a group] #linux
setfacl -d -m group:GROUPNAME:rwx /path/to/directory
setfacl -m group:GROUPNAME:rwx /path/to/directory

OR

Session follows:

/mnt/acl$ mkdir foo
/mnt/acl$ getfacl foo
# file: foo
# owner: faheem
# group: faheem
user::rwx
group::r-x
other::r-x
  • Set the group of foo to be staff, and set the acl of group and user of foo to rwx.
/mnt/acl$ chgrp staff foo
/mnt/acl$ setfacl -R -m u::rwx,g::rwx foo
/mnt/acl$ getfacl foo
# file: foo
# owner: faheem
# group: staff
user::rwx
group::rwx
other::r-x
  • Set default acls of user and group to rwx as well. This defines permissions that files and directories inherit from foo. So all files and directories created under foo will have group permissions rw.
/mnt/acl$ setfacl -d --set u::rwx,g::rwx,o::- foo
/mnt/acl$ getfacl foo
# file: foo
# owner: faheem
# group: staff
user::rwx
group::rwx
other::r-x
default:user::rwx
default:group::rwx
default:other::---
  • Now create some files in foo as users faheem and john.
/mnt/acl$ cd foo
/mnt/acl/foo$ touch bar

# switch to user john for this next command.
/mnt/acl/foo$ touch baz
  • List files. Notice that both files owned by faheem and files owned by john are created with group permissions rw.
/mnt/acl/foo$ ls -la
total 3
drwxrwxr-x+ 2 faheem staff  1024 May  9 01:22 .
drwxr-xr-x  4 faheem faheem 1024 May  9 01:20 ..
-rw-rw----  1 faheem faheem    0 May  9 01:20 bar
-rw-rw----  1 john   john      0 May  9 01:22 baz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment