Mac OS X from the command line

Dear Apple, I love you, but sometimes you drive me up the wall.

I've been playing around with a little project to set up sandbox drupal sites on a mac mini (more details on that later) ... that's easy stuff, but the annoying part is: I'd like to share directories via Samba which needs system accounts. The trick is, I want to add all of this via a simple little shell script. No problem right? Simple one line call to useradd... right?! Noooooooooo. Not in OS X. No, in OS X this is how you add user accounts from the commandline (which, of course, is under "Porting unix/linux applications"):

# dscl / -create /Users/portingunix
# dscl / -create /Users/portingunix UserShell /bin/bash
# dscl / -create /Users/portingunix RealName "Porting Unix
# dscl / -create /Users/portingunix UniqueID 503
# dscl / -create /Users/portingunix PrimaryGroupID 1000
# dscl / -create /Users/portingunix NFSHomeDirectory /Local/Users/portingunix
# passwd portingunix

I dunno... I think that's just annoying. Perhaps NetInfo has some beauty that I'm just don't understand, but, couldn't Apple at least ship with some standard useradd wrappers or something?

James Walker

James Walker (a.k.a. walkah) is an independent developer and hacker. He is a long time Drupal developer, but these days spends more time in Python, Ruby and Javascript.

You can follow him on twitter or github.

related posts