Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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

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?

share|improve this question
up vote 6 down vote accepted

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.

share|improve this answer
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
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 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.