Using sudo dscl to create new users with and without admin privileges. The newly created users for some reason are not in the login screen on bootup and using the input entries for users do not login into the account.

Commands I used:

sudo dscl . -create /Users/username

sudo dscl . -create /Users/username UserShell /bin/bash

sudo dscl . -create /Users/username RealName "John Smith"

sudo dscl . -create /Users/username UniqueID 1001

sudo dscl . -create /Users/username PrimaryGroupID 1000

sudo dscl . -create /Users/username NFSHomeDirectory /Local/Users/username

sudo dscl . -passwd /Users/username password

sudo dscl . -append /Groups/admin GroupMembership username

After using the commands the user is created in the users & groups yet they do not appear or are active in the login screen. My filevault is disabled and changing primary groups has not worked. I assumed that it may be because despite the fact that NFSHomeDirectory creates the home directory, the newly created user's home directory isn't created.

I currently have MacOSX El Capitan (10.11.6) and every attempt has failed. I would greatly appreciate some help since I put these commands into a C++ script to automate my user creation.

1 Answer 1


I notice you have a problem when creating a user via command line, but don't worry, there is a very easy way to do that with bash (terminal), without using Super User Do (sudo) or C++.

  1. firstly, you are to shutdown your machine. Turn off the computer and wait for about 30 seconds.

  2. Now hold ⌘ Command R until you see the Apple logo. Continue holding until you see this on your screen :

enter image description here

Alternatively you may see a list of users of your machine, log in and you should end up to this screen. If nothing works, try this over again by rebooting the computer.

  1. Now you are entering Recovery Mode. Select Disk Utility, and subsequently select the name of your machine and mount the disk if it is unmounted.

enter image description here

Now quit the Disk Utility, (⌘ Command Q ) and open the Terminal Utility by holding ⌘ Command ⇧ ShiftT.

  1. Now when the terminal is selected, type the following line :

    cd /Volumes/Macintosh\ HD/var/db

    And hit ⏎ Return .

  2. Then type this :

    rm .AppleSetupDone

    This will trick your mac into thinking that you didn't create a user yet and thus needing to open a setup document when you reboot the computer.

  3. The final text to type on the terminal is this :


7a. Now you may set up your new account.

`i` Don't worry!! Your files and your former account are not deleted, 
 they are all saved. After setting the new ADMIN account you will be 
 able to add and delete users, and manage your machine.

7b. To boot your former account just log out of the new account.

I hope this is clear and that it will help you.

  • How exactly is rerunning setup a way to have Finder’s Users and Groups see an account added via the command line?
    – Allan
    Commented Mar 14, 2023 at 18:39
  • Hey there, I notice that my explanations weren't clear enough. I owe you an apology as I am new here. So, What we are doing here is tricking your macbook into thinking that it has not created any user. Yet this won't delete any files or data stored inside the storage. This means that you will be able to create a new user without admin permissions. After logging in you then may add your former account to the admin group, with your new account. Hopefully this is clear... Thank you Commented Mar 15, 2023 at 8:25
  • It’s clear what your answer does, but you’re still using the GUI to set up an account . See step 7a. This completely defeats the purpose of the OP’s premise. I was asking ‘rhetorically* what your reasoning behind this was.
    – Allan
    Commented Mar 15, 2023 at 13:16
  • You may create your account once you reboot the computer, as you will find the setup screen as soon as you finish rebooting the machine. By the way, if you want i may show you a video where this works. This indeed does not need any former admin accounts to work. Commented Mar 15, 2023 at 16:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .