How do I create user accounts from the Terminal in Mac OS X 10.11? I would like to be able to create new users in Mac OS X 10.11 remotely after ssh'ing into the machine. On Mountain Lion, these steps were listed. 

Running

dscl . -create /Users/joeadmin
dscl . -create /Users/joeadmin UserShell /bin/bash
dscl . -create /Users/joeadmin RealName "Joe Admin" 
dscl . -create /Users/joeadmin UniqueID "510"
dscl . -create /Users/joeadmin PrimaryGroupID 20
dscl . -create /Users/joeadmin NFSHomeDirectory /Users/joeadmin
dscl . -passwd /Users/joeadmin password 

dscl . -append /Groups/admin GroupMembership joeadmin


After the above, the user doesn't become admin. What next?
If you are here and your system is running anything from 10.10 and newer, the sysadminctl command is your best friend. It does a lot of magic that DSCL can't do.

Here's the output for sysadminctl:

sysadminctl[21233:29122637] Usage: sysadminctl
    -deleteUser &lt;user name&gt; [-secure || -keepHome]
    -newPassword &lt;new password&gt; -oldPassword &lt;old password&gt; [-passwordHint &lt;password hint&gt;]
    -resetPasswordFor &lt;local user name&gt; -newPassword &lt;new password&gt; [-passwordHint &lt;password hint&gt;]
    -addUser &lt;user name&gt; [-fullName &lt;full name&gt;] [-UID &lt;user ID&gt;] [-password &lt;user password&gt;] [-hint &lt;user hint&gt;] [-home &lt;full path to home&gt;] [-admin] [-picture &lt;full path to user image&gt;]

Pass '-' instead of password in commands above to request prompt.


Then you'll want to do:

sudo createhomedir -c 2&gt;&amp;1 | grep -v "shell-init"


To add/remove users use dseditgroup:

sudo dseditgroup -o edit -a usernametoadd -t user admin
sudo dseditgroup -o edit -a usernametoadd -t user wheel