Friday, March 09, 2012

Create User accounts in Mac OS X

Reference: http://serverfault.com/questions/20702/how-do-i-create-user-accounts-from-the-terminal-in-mac-os-x-10-5


# Find out the next available user ID
MAXID=$(dscl . -list /Users UniqueID | awk '{print $2}' | sort -ug | tail -1)
USERID=$((MAXID+1))

# Create the user account
dscl . -create /Users/$USERNAME
dscl . -create /Users/$USERNAME UserShell /bin/bash
dscl . -create /Users/$USERNAME RealName "$FULLNAME"
dscl . -create /Users/$USERNAME UniqueID "$USERID"
dscl . -create /Users/$USERNAME PrimaryGroupID 20
dscl . -create /Users/$USERNAME NFSHomeDirectory /Users/$USERNAME

dscl . -passwd /Users/$USERNAME $PASSWORD

# Add user to group
dseditgroup -o edit -t user -a $USERNAME $GROUP

# Create the home directory
createhomedir -c -u $USERNAME

1 comment:

dimas geel said...

Nice info. :)

Please visit my blog
Just FYI, there’s an event for bloggers and the prizes are iPad2 and Cash. Find the info here. :)