This Article shows you How to Create a New User from Command Line on Mac OSX.
-
Open a Terminal Session
- Find an Unset Users ID:
usermaxid=$(dscl . -list /Users UniqueID | awk '{print $2}' | sort -ug | tail -1)
/nusernewid=$((usermaxid+1)) - Next Find the ID of the Group for the User:
groupid=$(dscl . -read /Groups/
PrimaryGroupID | perl -wlne 'print $1 if/(d+)/') -
Proceed to Create User and Set the Password:
dscl . -create /Users/newuser
dscl . -create /Users/newuser UserShell /bin/bash
dscl . -create /Users/newuser RealName "Lucius Q. User"
dscl . -create /Users/newuser UniqueID $usernewid
dscl . -create /Users/newuser PrimaryGroupID $groupid
dscl . -create /Users/newuser NFSHomeDirectory /Users/luser
dscl . -passwd /Users/newuser password - Create the User’s Directories Tree:
cp -R /System/Library/User Template/English.lproj /Users/newuser
chown -R newuser:staff /Users/newuser
-
To Add the New User to Admin Group:
dscl . -append /Groups/admin GroupMembership luser
Bless The Lord!