Did you know that you can navigate the posts by swiping left and right?

How To Set Default File Permissions For All Folders Files In A Directory

22 Mar 2017 . category: sysadmin . Comments
#sysadmin #linux #files #permission

Sometimes, we want to set a folder such that anything created within it (directories, files) inherit default permissions and group.

Lets call the group “media”. And also, the folders/files created within the directory should have g+rw automatically.

To archive this, we will use two tools: GID By setting the GID on the directory, files created within this directory will have the same group.


chmod g+s directory  //set gid 

ACL (man acl) We can now use ACL to create default permissions for newly created files in the directory


setfacl -d -m g::rwx /directory  //set group to rwx default 
setfacl -d -m o::rx /directory  //set other

Check the new permission:


getfacl /directory

Output:


# file: ..//
# owner: 
# group: media
# flags: -s-
user::rwx
group::rwx
other::r-x
default:user::rwx
default:group::rwx
default:other::r-x
</code></pre>


Me

Harry Nguyen is an awesome person. Abosolutely true!.