How to set permissions for folder in Unix/Linux Ubuntu
Solution 1
Found a nice article on this subject: What is the "umask"? How can I set it?
The
umask
defines the permissions a new file will get - or better: the permissions it will not get.[...]
If you want to define the
umask
for a specific directory (example: group write permissions for a directory you use together with your colleges), you'll become sweating when using the umask command because it is always valid for all directories.The solution of this problem is setting a default ACL. The following command ensures that all new files in
/home/shared/
have all permissions (including write permissions) set for the group:setfacl -d -m mask:007 /home/shared/
You should also set the sgid-bit for the directory and choose the wanted group using chgrp:
chgrp the_team /home/shared/ chmod g+s /home/shared/
If
/home/shared/
already contains subdirectories, you have to change their permissions as well. Tip: all mentioned commands know the -R option.
Solution 2
Set
umask 006
in your ~/.bash_profile
which is different from the default of 022. Also set
chgrp staff # or some other group you pick
chmod g+s blah
to enable the sticky bit on the directory. Now everything you create below it should retain the modes as well as the group.
Related videos on Youtube
Admin
Updated on September 17, 2022Comments
-
Admin over 1 year
This is not necessarily direct computer science question but its closely related.
Is there any way to do this.
I am using Z Shell zsh.
I want to set up so whenever i am in folder
~/blah
Everything I create is created using permissions 770 (All access wrx for me and group). Basically whatever I do in that folder should have those permissions.
In addition group for that file should be done in same way. But thats same process as the one for the permissions.
Anyone?
-
heijp06 over 14 yearsI think the OP is looking for a umask type setting that only applies to a specific folder