Monday, August 16, 2010

Adding Users In Leopard

How to add a user from the command line in Leopard (since it's apparently too much for Apple to include useradd-esque scripts).


dscl localhost -create /Local/Default/Users/zack
dscl localhost -create /Local/Default/Users/zack UserShell /bin/zsh
dscl localhost -create /Local/Default/Users/zack RealName "Zack"
dscl localhost -create /Local/Default/Users/zack UniqueID 502
dscl localhost -create /Local/Default/Users/zack PrimaryGroupID 1000
dscl localhost -create /Local/Default/Users/zack NFSHomeDirectory /Users/zack
dscl localhost -passwd /Local/Default/Users/zack changeme


Also to look at what UIDs already exist...


dscl localhost -list /Local/Default/Users UniqueID


Scripting this is trivial but I am lazy. ;)