With umask, I can determine the permissions for newly created files. But if I am a member of multiple groups, how do I set the default group for newly created files?

This question seems relevant, but its answers relate how the system administrator can change the default group for a particular user. I am not system administrator, but just a mere user, and have no permission to do usermod -g even on myself. So how would I proceed to set the default group for newly created files?


To change your default group on the fly, use newgrp:

newgrp some_group

After running that command, you will be in a new shell with your group set to some_group and files that you create will be in group some_group. newgrp may or may not ask for a password depending on how permissions are set.

Related: To find out which groups you belong to, run groups.

  • 1
    Just tested this, groups (at least on Arch) sorts them by numerical value, the primary group is not the first listed. Use id to get these details. – orion Mar 4 '14 at 19:30
  • @orion I checked the documentation and found nothing to support the claim about the primary group. Answer updated. – John1024 Mar 4 '14 at 19:48
  • 2
    It's important to note that newgrp launches a new shell. I don't think there's any way to change the default group for an existing process. – Keith Thompson Mar 4 '14 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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