Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > How do I add a user/group via command line

How do I add a user/group via command line
Thread Tools
Forum Regular
Join Date: Jan 2001
Location: Dallas, TX
Status: Offline
Reply With Quote
Jan 12, 2003, 05:41 PM
 
Does anybody know the unix commands to add a user or group via a command line?

thanks,.
     
Dedicated MacNNer
Join Date: Jul 2001
Location: NC
Status: Offline
Reply With Quote
Jan 12, 2003, 10:28 PM
 
   You can use nidump to dump your own user data into a file, alter the data to fit your new user and then use niload to upload the new data to NetInfo. Alternatively, you could fill that data into the following sequence of commands:

niutil -create / /users/<username>
niutil -createprop / /users/<username> name <username>
niutil -createprop / /users/<username> uid <UID>
niutil -createprop / /users/<username> "`openssl passwd '<Password>' `"
niutil -createprop / /users/<username> home <Home>
niutil -createprop / /users/<username> shell <shell>
niutil -createprop / /users/<username> gid <GID>

It shouldn't be difficult to alter the above commands to add a group, which contains considerably less data.
Gary
A computer scientist is someone who, when told to "Go to Hell", sees the
"go to", rather than the destination, as harmful.
     
Mac Elite
Join Date: Mar 2001
Location: Provo, UT
Status: Offline
Reply With Quote
Jan 12, 2003, 10:34 PM
 
Technically you have to use NetInfo. However NetInfo is a royal pain in the *ss.

I'd suggest downloading adduser and deluser for OSX. They mimic the standard utilities that come with Linux, OpenBSD and probably most other varieties of Unix.

http://freshmeat.net/releases/50923/

To do it with NetInfo you do the following:

mkdir /Users/username
niutil -create . /users/username
niutil -createprop . /users/username gid 0
nituil -createprop . /users/username uid 300
niutil -createprop . /users/username shell /bin/tcsh
niutil -createprop . /users/username realname "My Name"
niutil -createprop . /users/username home /Users/username
chown -R username /Users/username
passwd username

Everyone I know obviously uses the AddUser script.

For more NetInfo tips along with converting /etc files to NetInfo check out the following:

http://www.macaddict.com/osx/xphiles/12_05_00.html
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 08:08 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2