(macOS) Create a new user worklet

  • 20 September 2019
  • 3 replies

Userlevel 4

I'm exploring a custom worklet to create a new user.

So far this has been successful creating the user.
However when trying to login, the password does not work.

Please help if you think of a way around this.

sudo ddcl . -create /Users/automox
sudo dscl . -create /Users/automox UserShell /bin/bash
sudo dscl . -create /Users/automox RealName Automox
sudo dscl . -create /Users/automox UniqueID 9999
sudo dscl . -create /Users/automox NFSHomeDirectory /Local/Users/automox
sudo dscl . -passwd /Users/automox password123
sudo dscl . -append /Groups/admin GroupMembership automox

ps - Don’t use password123… I’m sure that goes without saying 🙂 Also there’s better ways to make users, but we’re trying to conjure this up for a specific use case.

This topic has been closed for comments

3 replies


great work here cfrieberg, dscl is indeed the preferred method for creating user accounts on macOS. One limitation of that tools is that it does not create a user’s home folder. Based on the last line it seems like you want this account to have admin rights, so I fixed that below as well.



dscl . -create /Users/"$user_short_name"
dscl . -create /Users/"$user_short_name" UserShell /bin/bash
dscl . -create /Users/"$user_short_name" RealName "$user_long_name"
dscl . -create /Users/"$user_short_name" UniqueID "$user_unique_id"
dscl . -create /Users/"$user_short_name" NFSHomeDirectory /Users/"$user_short_name"
dscl . -passwd /Users/"$user_short_name" "$user_password"
dscl . -create /Users/"$user_short_name" PrimaryGroupID 20 #for an admin user, use 80 for a standard user
cp -R /System/Library/User\ Template/English.lproj /Users/"$user_short_name"
chown -R "$user_short_name":admin /Users/"$user_short_name"
Userlevel 4

This is great! Thank you Tim.

I tested it out in a custom worklet, it successfully created a user account that I could log into.

I wonder if there’s a way to automate the account setup steps (siri, language, etc that come up after loggin in)

Thanks again!

There are ways to force a password reset on next login, if that seems like a nice feature to add.