The problem is that there is no useradd or adduser in OS X, so the user must
be added to the Directory Service by hand.
- First make sure to find an unused uid (unique ID) for the user,
dscl . -list /Users UniqueID
will list all the existing users, an unused number above 500 is good.
In general to list a property from the directory use:
dscl . -list {users|groups} {u|g}id
or to see the id's of an existing user use:
id auser
- The Add the directory entry:
dscl . -create /Users/luser
dscl . -create /Users/luser UserShell /bin/bash
dscl . -create /Users/luser RealName "Lucius Q. User"
dscl . -create /Users/luser UniqueID "503"
dscl . -create /Users/luser PrimaryGroupID 20
dscl . -create /Users/luser NFSHomeDirectory /Users/luser
The PrimaryGroupID=20 is usually staff. 80 is admin, it can be added with:
dscl . -append /Groups/admin GroupMembership luser
- Set the password:
dscl . -passwd /Users/luser password
or
passwd luser
- Finally, create the home directory with the appropriate permissions:
mkdir /Users/luser
chown luser:staff luser
or even better, create and populate the directory with
createhomedir -c -u luser
Further reading: http://serverfault.com/questions/20702/how-do-i-create-user-accounts-from-the-terminal-in-mac-os-x-10-5
No comments:
Post a Comment