[NTLUG:Discuss] persistent umask for a directory?

MadHat Unspecific madhat at unspecific.com
Wed Jul 11 12:07:29 CDT 2007


Chris Cox wrote:
> Stuart Johnston wrote:
>> Is there a way that I can have new files created in a particular 
>> directory automatically be writable by all users?
>>
>> I thought I had done this before but now I can't figure it out.
>>
> 
> Not easily.  You can have all files tagged with a particular
> group pretty easily.  Alternatively you can deploy ACLs, but
> that would not be my first choice (it can cause a plethora
> of problems unless you fully understand what you are doing).
> 
> To force group ownership (that is, that all files placed
> inside of a directory will have the same group owner):
> 
> $ mkdir mygroupdir
> $ chgrp somegroup mygroupdir
> $ chmod g+s mygroupdir
> $ chmod 770 mygroupdir
> 
> Now the only people with access to the dir is the
> owner of the dir and the members of somegroup.  When
> a member of somegroup writes into the dir, the file
> is created with the group of somegroup.
> 
> So... it's not exactly what you were looking for, but
> this might be useful.
> 
> In order to do the above things as a normal user,
> the user must belong to somegroup (does not need
> to be the primary group of that user though).


I was working on the same reply...  you can also do
chmod 2770 mygroupdir


# mkdir tmp
# chgrp users tmp
# chmod 2775 tmp
# touch tmp/file
# ls -al tmp/
total 12
drwxrwsr-x   2 root users 4096 Jul 11 12:03 .
drwxr-xr-x  11 root root  4096 Jul 11 12:01 ..
-rw-r--r--   1 root users    0 Jul 11 12:03 file




More information about the Discuss mailing list