I'm Jonathan Bullock; creator of JBake, developer with a passion for the Internet, geek, gadget lover and fan of far too many sports. I occasionally give talks and tweet every now and then.
22 June 2008
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!