Skip to main content

Adding a user to your system is quite simple via the GUI, however there may be times you wish to mass deploy or run via a script. Below shows the commands on how to do this. Adding a new user to a Mac computer from a Terminal window requires you to define the user’s name, set a password, create the user’s home directory and configure her system permissions.

Please note, that we recommend to always backup or test commands prior mass deployment.

  1. Open a Terminal window. Search in finder TERMINAL and double-click the “Terminal” icon.
  2. Type “sudo dscl . -create /Users/username” and press “Enter.” Replace “username” with a one-word name to identify the user. Replace all instances of “username” in future steps with the same one-word name. Enter your computer’s administrator password and press “Enter” again. The prompt drops to the next line.
  3. Type “sudo dscl . -create /Users/username UserShell /bin/bash” and press “Enter.”
  4. Type “sudo dscl . -create /Users/username RealName “John Smith”” and press “Enter.” Replace “John Smith” with the new user’s full name.
  5. Type “sudo dscl . -create /Users/username UniqueID 1001” and press “Enter.” The number after “UniqueID” must be an ID number that is not assigned to another user.
  6. Type “sudo dscl . -create /Users/username PrimaryGroupID 1000” and press “Enter.”
  7. Type “sudo dscl . -create /Users/username NFSHomeDirectory /Local/Users/username” and press “Enter.” This creates a home folder for the new user.
  8. Type “sudo dscl . -passwd /Users/username password” and press “Enter.” Replace “password” with the desired password that the new user will use when logging in to the computer. You may need to type your computer’s administrator password again to complete this action.
  9. Type “sudo dscl . -append /Groups/admin GroupMembership username” and press “Enter” to give the new user administrative privileges. To make the new account a limited user account, skip this step.

Thank you

4.4.2024 Edit: PLEASE NOTE: These commands may not work in later versions of OSX after Monteray.
Here is a community link have found with more updated information at stackexchange.com :
macos – How do I create user accounts from the Terminal in Mac OS X 10.11? – Ask Different (stackexchange.com)

21 Comments

  • Mark Pace says:

    Thanks for your comments – I have updated the post (as it is old and havent used it for sometime) refering to stackexchange.com for more later info.
    https://apple.stackexchange.com/questions/226073/how-do-i-create-user-accounts-from-the-terminal-in-mac-os-x-10-11/292859#292859

  • toke says:

    People make these guides and always miss to tell that Apple changes these things every year.

    This guide will work with newest OS version when this was written.

  • Mike says:

    Find a free unique id for the unbound user in the 1-500 range (reserved for system accounts). For example, 444.

    $ dscl . -list /Groups PrimaryGroupID | grep 444
    $ dscl . -list /Users PrimaryGroupID | grep 444
    If you have no output for those two commands, you can proceed to actually create the user and group.

  • Dominic says:

    Same, all commands work except the password one. Running “resetpassword” afterwards tells me I have no accounts

  • Harry says:

    Same here no home directory….will mkdir fix that?

  • melissa says:

    that’s doin way too much. There should be a easier way

  • Atul says:

    Hi,
    for me the home directory is not being created, any one aware about this issue.

  • cristian says:

    same issue here, using a bash script that used to work.

  • Kublai says:

    Same here 🙁

  • Andy Cook says:

    Using macOS Monterey.

    All commands seems to be accepted yet no account is created Users & Groups setting or folder in users area.

    Odd!

  • Admin says:

    Reboot computer into recovery change boot disk password boot into single user mode then mount disk and load the .plist file then run these commands

  • Danno says:

    underlying UNIX always has UID and GID. User & group names are mapped to UID & GID, like DNS-names always has to resolve to IP address number if you want to get anywhere

  • ash k says:

    get the same password error. Also through recovery sudo doesn’t work either.

  • Steve says:

    Do I need to do all the steps? Specifically: Type “sudo dscl . -create /Users/username UniqueID 1001” and press “Enter.” The number after “UniqueID” must be an ID number that is not assigned to another user.
    Type “sudo dscl . -create /Users/username PrimaryGroupID 1000” and press “Enter.”

    We don’t use id numbers or group id numbers.

    Thanks,

    Steve

  • bounoun says:

    Hi,
    when I try “sudo dscl . -passwd /Users/username password” I have n error “passwd : DS error: eDSOperationFailed”

  • Max says:

    How many users can you create? After about 200 the Mac ran out of processes and crashed.

  • Mark Pace says:

    When you type the password, it is invisible. So type slowly and ensure correct then press enter at the end

  • Mark Pace says:

    The only time I have seen this not work is on the latest OSX – though some have said no issues. Make sure AV is also disabled.

  • Jennifer Gillespie says:

    After unique ID I keep getting error messages no such file or directory. I’ve tried several numbers

  • gu says:

    Everything works fine up until the password, I cannot type a password in the terminal

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.