Terminal – Creating User Accounts from Terminal on MacOS 10.11

command linemacossshterminal

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?

Best Answer

The documentation lacks one important step:

reboot

or

sudo reboot

After the reboot the user enjoys visible admin rights in System Preferences -> Users and Groups.

But: even without rebooting the user is admin already - it's just not visible in the PrefPane. If you login as joeadmin immediately after creating the account (e.g. fast user switching) the admin role is visible from within his account.