終端機建立新使用者 By Mac OS X

| Mac OS X

那天客戶的電腦突然進不去系統,於是透過terminal終端機去建立新的一般使用者,再把這個使用者提升到admin的權限

The following commands can be used to create a new user in Terminal via SSH:

dscl . -create /Users/new_user
dscl . -create /Users/new_user UserShell /bin/bash
dscl . -create /Users/new_user RealName “USER NAME“
dscl . -create /Users/new_user UniqueID 503
dscl . -create /Users/new_user PrimaryGroupID 20

PrimaryGroupID of 80 creates an Admin user. Change to PrimaryGroupID of 20 to create a Standard user.

dscl . -create /Users/new_user NFSHomeDirectory /Users/new_user
dscl . -passwd /Users/new_user changeme
dscl . append /Groups/admin GroupMembership new_user

You may need to create the home directory as well:

createhomedir -u new_user

參考原文出處:http://dareneiri.github.io/Creating-A-New-User-in-Terminal/