Created
April 17, 2018 15:11
-
-
Save fjlopezs/0adc08fd268f31d243c1d6c54bab084c to your computer and use it in GitHub Desktop.
Creating a Mac OS X user via shell script with a prompt password
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/sh | |
# https://apple.stackexchange.com/questions/82472/what-steps-are-needed-to-create-a-new-user-from-the-command-line/84039#84039 | |
LastID=`dscl . -list /Users UniqueID | awk '{print $2}' | sort -n | tail -1`; | |
NextID=$((LastID + 1)); | |
NewUser=administrator | |
. /etc/rc.common | |
dscl . create /Users/$NewUser | |
dscl . create /Users/$NewUser RealName "Admin" | |
# dscl . create /Users/$NewUser hint "Password Hint" | |
# curl -LJO "http://site.com/Picture.png" | |
# dscl . create /Users/$NewUser picture "/Path/To/Picture.png" | |
dscl . create /Users/$NewUser UniqueID $NextID | |
dscl . create /Users/$NewUser PrimaryGroupID 80 | |
dscl . create /Users/$NewUser UserShell /bin/bash | |
dscl . create /Users/$NewUser NFSHomeDirectory /Users/$NewUser | |
cp -R /System/Library/User\ Template/English.lproj /Users/$NewUser | |
chown -R $NewUser:staff /Users/$NewUser | |
# Append as admin member | |
dscl . -append /Groups/admin GroupMembership $NewUser | |
dscl . passwd /Users/$NewUser |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.