Give default write permission to group to any newly created files and folders

grouppermissions

Let's say that we have 2 users: a and b, that are both part of group general.

I would like that any file or folder that A creates, would have write permission to the group GENERAL.

How can I do it?

For instance, the newly created file is set as:

-rw-r--r-- 1 a general

This doesn't give write permission to the group general

Best Answer

Yes, you can do that changing the umask. The umask determines which are the default permissions for a newly creted file.

You can add umask g+w at the end of your shell configuration file (~/.bashrc for example).

But actually, it´s not a recommendable practice. In the case you do want to ensure the integrity of a file and you forget to update the file permissions, it will be modifiable by the group. It's against the "secure initial values" principle of security.

What you could do instead is make all the newly created file of a specific directory writable by the group. You can do this manipulating the ACLs of the directory. For example, setfacl -dm u::rw,g::rw,o::r ~/shared.

Look at those posts for reference : https://serverfault.com/questions/349145/can-i-override-my-umask-using-acls-to-make-all-files-created-in-a-given-director and https://stackoverflow.com/questions/580584/setting-default-permissions-for-newly-created-files-and-sub-directories-under-a.

Related Question