Make new files take on the same group as the directory | Ubuntu | Linux
Published by Nicholas Dunbar on March 12th, 2013
If you want all files created in a directory to carry a certain default group owner, change the files immediate folder to use the permission bit "s"
user@localhost the_directory> chmod g+s your_dir_name
This will make it so, if you cd your_dir_name and you then create a new file it will automatically have the same group as the group owner in the parent directory your_dir_name.
Let's take a closer look at what is going on here.
chmod - this is a command that changes the permissions of a file
g+s - this adds the permission bit "s" on to your folder for the group (g). "s" is a special permission bit (the set id bit) that says any new files under this directory will have the same group ownership that the folder which contains it has.
your_dir_name - replace this with the directory name you want to set up with the new file permissions
Tested on Ubuntu Linux. On a Mac the default is to take on the ownership of the directory, so in that case the permission bit would not matter.