Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Create new users from the Terminal in 10.3' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create new users from the Terminal in 10.3
Authored by: Cap'n Hector on Nov 03, '04 11:41:36AM
A second option is to use this shell script:

echo "Enter username:"
read new_username
echo "Enter the full name for user $new_username's:"
read long_name
echo "Will $new_username an Admin user (y/N)?"
read godlike_powers
new_uid=`nidump passwd . | awk -F: '{print $3f}' | sort -n|tail -1`
new_uid=`expr $new_uid + 1`
nicl . -create /users/$new_username
nicl . -create /users/$new_username uid $new_uid
nicl . -create /users/$new_username realname "$long_name"
nicl . -create /users/$new_username passwd ""
nicl . -create /users/$new_username gid 20
nicl . -create /users/$new_username shell "/bin/tcsh"
nicl . -create /users/$new_username home "/Users/$new_username"
nicl . -create /users/$new_username _writers_passwd $new_username
passwd $new_username
ditto /System/Library/UserTemplate/English.lproj /Users/$new_username
chown -R $new_username:staff /Users/$new_username
nicl . -read /users/$new_username
if [ "$godlike_powers" = Y -o "$godlike_powers" = y ]
nicl . -append /groups/wheel users $new_username
nicl . -append /groups/admin users $new_username
nicl . -read /groups/wheel
nicl . -read /groups/admin

[ Reply to This | # ]
Create new users from the Terminal in 10.3
Authored by: ClassicUser on Nov 03, '04 11:51:09PM

Not bad, but still quite a few problems - especially regarding Panther-style users (since this primary hint indicates it is for 10.3):

- While this copies from the English.lproj sub-folder of the User Template area, it should also merge the contents from Non_localized
- The "sharedDir" entry really should be set in the user record (set to a value of "Public"), to ensure AFP file sharing is functional for that user
- Panther: This doesn't consider the custom group created by default, and the custom GID used for this group. The group assigned to the user's home, as well as the GID entry in NetInfo, should use this - instead of "staff"
- Panther: The default shell should be /bin/bash - not /bin/tcsh
- There are several _writers_xxx entries which still should be set in NetInfo, as well
- Even an admin user should NOT be added to the "wheel" group

And, note that none of these scripts handle the creation of a password. This could be handled as an additional feature of the script, to ensure the created user is completely implemented. But also note that as of Panther, the authentication_authority should be set to ";ShadowHash;", not ";basic;" - along with a associated shadow password hash implementation (lots of details to be considered here...).

In all: Creating users is something which is done very well by Apple's UI - and changes with every major release. While automating this process sounds like a good idea, if it's not done completely and exactly correctly, the user created could encounter significant problems on the target computer.

[ Reply to This | # ]
Authored by: ssevenup on Nov 30, '04 02:01:13PM

I took a look in Non-Localized and found nothing there that looked useful. It sets up SoftwareUpdate scheduling which we purposely turn off here. And the Cache looks like it's fluff. Not that I disagree that this is a very complex undertaking, not to be taken lightly. Your other comments I agree with completely.


Mark Moorcroft
Sys. Admin.

[ Reply to This | # ]
Create new users from the Terminal in 10.3
Authored by: juanfc on Nov 04, '04 12:59:08PM

There is a space in the "User Template" name
ditto "/System/Library/User Template/Spanish.lproj" /Users/$new_username


[ Reply to This | # ]