How to set umask for a folder and it's subfolder?

42,341

I assume that you did already:

chmod g+rwxs directory

and now you have to make sure that the users have a umask like 002. To setup the umask for all the users, try in /etc/bashrc or /etc/profile.

caveat: you cannot setup a umask per directory as it's a process level thing.

Interesting read http://www.cyberciti.biz/tips/understanding-linux-unix-umask-value-usage.html

Share:
42,341

Related videos on Youtube

Cyril N.
Author by

Cyril N.

Updated on September 18, 2022

Comments

  • Cyril N.
    Cyril N. 3 months

    I'm working on the same directory with some friends and they access it via SSH.

    I added us in the same group and defined a sticky bit to keep the user:group values the same.

    But when a user create a file/folder, the Write attribute is not defined for the group, disabling other to write it/on it.

    How can I define the Umask to add the Write value for groups in the specific directory and it's subfolders ?

    I tried to find some help before, but I only saw helps for Fedora/CentOs, and I'm using Debian Squeeze.

    Thanks for your help

  • Cyril N.
    Cyril N. over 9 years
    Thanks for this help. Does it works when using ssh over git ?
  • zekus over 9 years
    tbh I am not sure but, because you are using a unix user anyway even with git, in theory it should work.
  • Ryu_hayabusa almost 8 years
    umask 002 ~ chomd 775
  • bricklore
    bricklore about 7 years
    You actually can set a umask per directory using Linux ACLs, e.g. use setfacl -R -m group:groupname:rw-,d:group:groupname:rw- directory/ to force the r and w permission for the group "groupname" on a directory