Tutorial :Mac OS X New Users From Command Line


I need to add a new user via the command line in single-user mode. I reinstalled OS X earlier, and for some reason, it didn't create my user account properly. Now I can't log in. So I'm wondering how exactly I can go about creating a new user account without reinstalling everything.

I tried this, but it didn't work: http://osxdaily.com/2007/10/29/how-to-add-a-user-from-the-os-x-command-line-works-with-leopard/

Thanks in advance.


rm /var/db/.AppleSetupDone  

...and then reboot normally. With that file gone, OS X launches its first-run Setup Assistant and (among other things) lets you create a new account.

BTW, the reason niutil isn't there has nothing to do with whether it's a server or not -- it's because Apple got rid of NetInfo (its old database for storing local users) in 10.5, and replaced it with a new XML-based system. If you want to do niutil-ish things in 10.5, you can either use dscl (this is actually a bit complicated in single-user mode because directory services aren't running) or create/edit the XML files by hand.


As of 10.10 you can use the sysadminctl command to add a user, in this case prompting for the password and adding them to the admin group:

sudo sysadminctl -addUser collin -password - -admin  




I know it's a bad idea to install Puppet just for this task, but if you're a puppet user and you want a cross-platform solution:

Create the file, user.pp, containing:

group { 'jenkins':    gid        => '507',  }    user { 'jenkins':    ensure     => present,    uid        => '507',    gid        => '507',    shell      => '/bin/zsh',    home       => '/Users/jenkins',  }     file { '/Users/jenkins':    ensure => directory,    before => User['jenkins'],  }   

and then execute it with: puppet apply user.pp.

Note that you should change the username (jenkins) and gid/uid as necessary.


Seems like if it didn't create your user account correctly you probably need to reinstall again in case other things didn't get set up correctly.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »