Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

OS X: creating/listing users at the command line

3 views
Skip to first unread message

Nick Winters

unread,
Aug 20, 2002, 6:22:41 PM8/20/02
to
Hi all,

Has anyone created an OS X user at the command line rather than
through the netinfo interface? In some linux distributions there's
scripts (adduser or useradd) that allow you to create users at the
command line.
Is there anything similar with OS X.

In a similar vien, is their a command line way of listing all the
users?
(Using netinfo, I see about a dozen users (ex. mysql, game, postfix,)
and these names aren't in the /etc/passwd file.)

Thanks,

Nick

Matthew Smith

unread,
Aug 20, 2002, 7:48:12 PM8/20/02
to
In article <b5b44f5a.0208...@posting.google.com>,
milke...@yahoo.com (Nick Winters) wrote:

Mac OS X does not use the /etc/passwd file. It uses the NetInfo
database, which is also used to replace a lot of other unix data files.

The commands that deal with the NetInfo database start with ni. Type
"man ni" and then tab. You will see a list of commands starting with ni
(including ones that don't work with the NetInfo database.

If you want to see all the users in /etc/passwd format then type:

nidump passwd /

--
Matthew Smith
(to reply via email replace xxx with net)

Hugo Wolf

unread,
Aug 20, 2002, 8:18:35 PM8/20/02
to
In article <msmith8-C3F703...@mec2.bigpond.net.au>,

Matthew Smith wrote:
> If you want to see all the users in /etc/passwd format then type:
>
> nidump passwd /

Correspondingly, you can load a set of passwords in passwd format via

niload -d passwd . < [passwd-file]


So writing an adduser script should be simple enough: construct the
appropriate passwd line, then echo it into niload:

line=[extract the args and construct the passwd line]
echo $line | niload -d passwd .

--
d f-d


Nicolas Seriot

unread,
Aug 20, 2002, 9:55:32 PM8/20/02
to
Hugo Wolf <hw...@deutsche.lieder.net> wrote:

> So writing an adduser script should be simple enough

Don't bother.

#!/bin/zsh
# Script to add users by Stewart Walker

echo "Login account?"
read inp
if [ "x$inp" = "x" ]
then
echo "login needed"
exit
fi

log=$inp
echo "Full name?"
read inp
if [ "x$inp" = "x" ]
then
echo "Full name needed"
exit
fi

nam=$inp
echo "UID ? (next free after 100, this script does no checking)"
read inp
if [ "x$inp" = "x" ]
then
echo "UID needed"
exit
fi

uid=$inp
echo "Shell ? (/bin/zsh by default)"
read inp
if [ "x$inp" = "x" ]
then
inp="/bin/zsh"
fi

shl=$inp
echo "Home Dir? (/Local/Users/$log by default)"
read inp
if [ "x$inp" = "x" ]
then
inp="/Local/Users/$log"
fi
hom=$inp

echo "Can this user su to root (no by deault, otherwise type yes) ?"
read inp
if [ "x$inp" = "xyes" ]
then
gid=0
else
gid=20
fi

niutil -create / /users/$log
niutil -createprop / /users/$log shell $shl
niutil -createprop / /users/$log passwd ""
niutil -createprop / /users/$log realname $nam
niutil -createprop / /users/$log uid $uid
niutil -createprop / /users/$log gid $gid
niutil -createprop / /users/$log _shadow_passwd
niutil -appendprop / /groups/staff users $log
if [ "$gid" = "0" ]
then
niutil -appendprop / /groups/wheel users $log
fi
mkdir $hom
niutil -createprop / /users/$log home $hom
passwd $log
chown $log $hom
chgrp staff $hom
niutil -read / /users/$log
exit

--
Nicolas Seriot
www.seriot.ch

David

unread,
Aug 21, 2002, 12:47:24 AM8/21/02
to
milke...@yahoo.com (Nick Winters) wrote in message news:<b5b44f5a.0208...@posting.google.com>...

Check out man niutil, man niload, man nidump, etc.

David

John C. Randolph

unread,
Aug 21, 2002, 2:28:07 AM8/21/02
to

Open a terminal window, and type "man nicl".

-jcr

0 new messages