Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In a modern Linux distro, I want the files created under /path/to/files to have a default group of mygroup. It seems on some distributions this can be done by grpid, which doesn't exists on Ubuntu. What is the standard way of accomplishing this?

share|improve this question

You just need to set the group ownership and then set the group setgid bit on the parent directory.

$ chgrp -R mygroup /path/to/mydir
$ chmod g+s /path/to/mydir
share|improve this answer
It seems this only changes the permission of new files to something like -rw-r-Sr-- but the group is not changed. – ubt Dec 22 '12 at 14:33
@ubt The first command here sets the group of existing files and the directory. The second command changes the directory itself, new files created in the directory (because of the "setgid" bit on the group permissions) will inherit the group of the directory itself. So if the directory is owned by "mygroup" then new files will be owned by them as well (unless specified otherwise in the creation process). – Chris S Dec 23 '12 at 15:49

Use the setgid permission with

chmod g+s directoryname
share|improve this answer
Also needs to have the directory owned by the "mygroup" group, but close enough for a +1 – Chris S Dec 23 '12 at 15:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.