Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


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.


share|improve this question

migrated from Oct 12 '09 at 15:50

This question came from our site for professional and enthusiast programmers.

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.

share|improve this answer
I think the OP is looking for a umask type setting that only applies to a specific folder – heijp06 Oct 12 '09 at 15:41


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.

share|improve this answer

Don't forget that the filesystem must be mounted with the 'acl' flag in order to use access control lists. Otherwise the setfacl command will return 'Operation not supported'.

For example this is the entry in my fstab file (/etc/fstab):-

# <file system>  <mount point>     <type>  <options>   <dump>  <pass>
/dev/sdb1        /media/DataDrive  ext3    acl         0       0
share|improve this answer

You can define a chpwd() function which will be run every time the cwd of the shell is changed. Inside there, test the directory and set umask appropriately.

function chpwd {
  [[ $PWD == $HOME/blah ]] && { umask 007; return }
  # or, if more tests here, use case $PWD in ... esac
  umask 022
share|improve this answer

umask will change the default permissions for a every file and directory you will create, but if you need this behavior to be only for a given directory you should look at access control lists ACLs see: man acl(5) for more information.

share|improve this answer

You must log in to answer this question.