2

I'd like to make new files, created in a directory, writable by others in the same Posix group without using ACLs. Not sure this is possible.

The way I've accomplished this in the past was to change every users umask to 0002 and then chmod g+w+s on the directory containing the shared files (output edited for brevity):

$ mkdir shared ## create a shared location
$ ls -lart
drwxr-xr-x  2 user234 sysadmin 4096 Mar  1 10:02 shared

$ groups ## must be member of group to share with
sysadmin webdevel sysconfig

$ chmod g+w+s shared ## set new files for group write/:sysconfig ownership
$ chown :sysconfig shared
$ ls -lart
drwxrwsr-x  2 user234 sysconfig 4096 Mar  1 10:02 shared

$ touch shared/file1 ## need umask for group write?
$ ls -lart shared/file1 
-rw-r--r-- 1 user234 sysconfig 0 Mar  1 10:03 shared/file1

$ umask
0022          ## no group write bits

$ umask 0002  ## set umask to add group write by default

$ touch shared/file2 ## ok fine                                                                                                
$ ls -lart shared/file2
-rw-rw-r-- 1 user234 sysconfig 0 Mar  1 10:03 shared/file2

$ touch ~/tps_reports  ## files created in home are GW now as well
$ ls -lart ~/tps_reports
-rw-rw-r-- 1 user234 sysadmin 0 Mar  1 10:08 /home/user234/tps_reports

The problem with changing the umask is when users create files elsewhre (for instance in their home directories where group read/write isn't typically wanted) these also have group-write by default since umask affects files across the local filesystems. Are ACLs the only way to fix this?

3
  • Can you change your comments from << to a # character? The << is a a bash IO redirection operator.
    – 111---
    Mar 1, 2018 at 22:13
  • How are the files being created? In an interactive shell session or programmatically?
    – 111---
    Mar 1, 2018 at 22:16
  • (arrows changed, thanks) Interactive shell logins Mar 2, 2018 at 14:04

0

You must log in to answer this question.

Browse other questions tagged .