Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

2 Answers

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
add comment

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
add comment

Your Answer

 
discard

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.