Created
August 11, 2015 14:19
-
-
Save cuibonobo/78053e9e301347a1bbf3 to your computer and use it in GitHub Desktop.
Create a user from the command line on Mac OS X
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # This must be run as root. Needs to ask for password interactively and get the next unique | |
| # user ID automatically, but you get the idea. | |
| USERNAME='username' | |
| USER_ID=510 | |
| DISPLAY_NAME='User Name' | |
| PASSWORD='password' | |
| dscl . -create /Users/${USERNAME} | |
| dscl . -create /Users/${USERNAME} UserShell /bin/bash | |
| dscl . -create /Users/${USERNAME} RealName "${DISPLAY_NAME}" | |
| dscl . -create /Users/${USERNAME} UniqueID ${USER_ID} | |
| dscl . -create /Users/${USERNAME} PrimaryGroupID 1000 | |
| dscl . -create /Users/${USERNAME} NFSHomeDirectory /Local/Users/${USERNAME} | |
| dscl . -passwd /Users/${USERNAME} ${PASSWORD} | |
| # If you need to make this user an administrator, do: | |
| dscl . -append /Groups/admin GroupMembership ${USERNAME} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment