chimpsky

Q: Changing Primary Group

Hi there,

 

Creating files results in the groupname set to "staff." I assume this is set by the primary group of the user? However, after changing my user's primary group, newly created files still show staff as the groupname. I set the primary group with the following command:

 

sudo dscl . -create /Users/<username> PrimaryGroupID <groupid>

 

and when that didn't have an effect, I set the primary group through System Preferences --> Users and Groups. Using the groups command, I can see the desired group is the first one listed in the output.

 

Any ideas how to change the default groupname of created files?

 

Thanks,

MacBook Pro, OS X Mavericks (10.9.5)

Posted on Sep 30, 2014 11:01 PM

Close

Q: Changing Primary Group

  • All replies
  • Helpful answers

  • by BobHarris,

    BobHarris BobHarris Oct 1, 2014 4:14 PM in response to chimpsky
    Level 6 (19,410 points)
    Mac OS X
    Oct 1, 2014 4:14 PM in response to chimpsky

    From the X/Open standards

     

    open()

    ...

    O_CREAT

    If the file exists, this flag has no effect except as noted under O_EXCL below. Otherwise, the file shall be created; the user ID of the file shall be set to the effective user ID of the process; the group ID of the file shall be set to the group ID of the file's parent directory ...

  • by chimpsky,

    chimpsky chimpsky Oct 1, 2014 10:02 PM in response to BobHarris
    Level 1 (0 points)
    Oct 1, 2014 10:02 PM in response to BobHarris

    Thanks for the reply... I'm kicking myself for not finding this explanation myself.

  • by basilmir,

    basilmir basilmir Jan 8, 2016 3:27 PM in response to chimpsky
    Level 1 (76 points)
    Jan 8, 2016 3:27 PM in response to chimpsky

    I think changin the umask will do exactly what you're after.

    Umasks

    The POSIX permissions on a file can be represented by a number with three digits. You might see permissions listed this way when viewing them from the Terminal. Each digit can be zero through seven. When you create a file, the umask value is subtracted from a default value (usually 666 for files, 777 for folders) to determine the permissions on the new file or folder.

    For example, the default umask of 022 results in permissions of 644 on new files and 755 on new folders. Groups and other users can read the files and traverse the folders, but only the owner can make changes.

    There are several different places where the umask can be set, each affecting different apps.

     

    sudo launchctl config user umask nnn

     

    See this:

    Setting a custom umask in OS X - Apple Support