Say you want to set a folder such that anything created within it (directories, files) inherit default permissions and group.
Let’s call the group “users”. And also, the folders/files created within the directory should have g+rw automatically.
To do this follow below steps:
chmod g+s /path/to/directory //set gid setfacl -d -m g::rwx /path/to/directory //set group to rwx default setfacl -d -m o::rx /path/to/directory //set other
# file: ../path/to/directory/ # owner: <user> # group: media # flags: -s- user::rwx group::rwx other::r-x default:user::rwx default:group::rwx default:other::r-x
Why chmod g+s?
This will ensure that new content in the directory inherits the group ownership.
Note: ACL must be enabled (included as one of the mount options for the mounted file system) for the file permissions to be inherited.