Set Group ID permission in Linux

How to set the default group for files and directories created under a certain directory. By default Linux uses the group of the user account used to create the file, on Debian this is usually users. The following commands should be run under the root account.

First change the group on the directory to the one you want to be used as the default:

chgrp group /path/to/directory

Then set the Group ID permission on the folder:

chmod g+s /path/to/directory

That's all you need to do if the directory is empty, every file or sub directory created underneath this directory will inherit the group value we've set. If you already have sub directories in this directory and you want to set the default group value on those too then you'll need to run the following command:

find /path/to/directory -type d -exec chmod g+s {} \;

That's it, job done!