Ensuring new files in a directory belong to the group
Problem
I want to create a shared directory when a number of users (all belong to say mygroup) can create and edit files. I would like all files in this directory and subdirectory to belong to mygroup I have changed existing files to have group mygroup using , but new files still get created belong to the user's primary group. Is there a way of ensuring new files belong to the group without repeatedly running chgrp.
Error Output
chgrp
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Fix for: Ensuring new files in a directory belong to the group
You want to set the SetGID bit. All new files created in the directory will have the group set to the group of the directory. A superuser blog post explained the sticky bits and other Linux permission bits: SetGID, however, is a whole different ball game. When a directory has the SetGID bit set and a file is created within that directory the group ownership of the file is automatically modified to be the group of the directory.
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix