We have a mixed mac and linux environment at work, to make life easy we use the same uid, gid for each user both on the mac and linux side (I believe this is a standard practice).

The problem is, when you add a new user on a mac, there is no way to set the uid and gid "while" you are creating it, so you need to add the user then set the uid/gid and then go and execute a few find ... -exec ...{} ... commands to change the owner and permissions on the home directory for the user that you already made,

Is there a better solution for this?

1 Answer 1


One solution would be to write a simple script to do the whole job at once.

dscl . -create /Users/ali UniqueID 549 PrimaryGroupID 320 RealName "Ali Moeeny" 

Or something like that.

  • 1
    Problem is, I often find this non unix tools that Apple adds to macosx (like dscl instead of adduser ...) very unintuitive.
    – Ali
    Commented Dec 20, 2011 at 20:50
  • The problem with this is, the new user does not show up in the Users & Groups preference pane afterwards, and you can't actually log in as the user. Or perhaps one should take the “or something like that” addendum a bit more seriously, and actually read the dscl man page … Commented Jun 11, 2012 at 11:29
  • If you set the uid above 500 it would show up in the Preferences and you can login as well, I think you can login even if it's uid is below 500 but you need to choose other (pre-lion) and enter both user name and password.
    – Ali
    Commented Jun 12, 2012 at 13:34
  • Didn't work for me, with uid=13799. Anyhow, it was easy enough to change the uid after the fact. (By command line or GUI. I only had to do it for two users …) Commented Jun 12, 2012 at 17:43
  • Could you elaborate on how to change the UID for an existing user after the fact? What commands do you need to run or what files do you need to edit to change the user's UID? I'm comfortable with a Unix command line, but want to know the Mac-specific stuff. (On a Unix box, I know I'd need to change /etc/password, /etc/group, and do a chgrp -R to change the uid/gids on all existing user files. What about on MacOSX?)
    – D.W.
    Commented Jul 17, 2012 at 6:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .