Subject: Adding users (longish)
To: jtn2@email.psu.edu, port-mac68k mailing list <port-mac68k@netbsd.org>
From: Steve Revilak <revilak@umbsky.cc.umb.edu>
List: port-mac68k
Date: 12/19/1998 12:23:11
>2. Now for the stupid question. I'm still pretty new to netbsd. I have a
>couple of basic unix books that I am working through, but neither cover
>much in the way of system administration. How does one add a new user? (I
>assume that when I get this think on the net, being logged in as root is a
>pretty bad idea.)

Part of the problems is that root is capable of accidentally doing more
damage than a normal mortal user :-)

If you'd like a good book that addresses administrations issues "The Unix
System Administrator's Handbook" by Nemeth, Snyder, Seebass is one of the
more highly regarded ones.  There's plenty of good information in there --
more than you'll hopfully ever need (how to hand-edit rulesets in
sendmail's configuration file!).

In the bookstore, it's the bright red one with the monkey on the cover.  I
wrote up something of a how-to in response to this question some months ago
(right after I had figured it out, actually).  I'll add a few minor tweaks
and repost...hopfully no one is sick of seeing this.

Actually -- would I be out of line in considering the submission of a more
formalized version of this as a how-to (with appropriate disclaimers to the
fact that there are a number of ways to do this.)  Suggestions?

================================================================

>Can someone point me to a page (a page that is actually UP, not the *dead*
>links mentioned in the faq) that has these instructions?  Or, could someone
>just write these instructions down and email them to me, or better yet,
>post
>them somewhere?

I'm still new enough of a newbie to have wrestled through this fairly
recently...

Preliminary places to start-- man pages for adduser (general info for
adding a new user) and passwd (for the formatting of data in
/etc/master.passwd).  To begin, I logged in as root in multi-user mode....

I remember encountering the vipw error you mention. I believe I got around
that by logging in as root, and using the command 'chfn' to change roots
finger information (root is line 1 of the master.passwd file).  Then,
'pwd_mkdb /etc/master.passwd' to rebuild the password database files.

Okay, so you're logged in as root.  You'll need to edit /etc/master.passwd.
Use 'vipw' or just edit the file directly ('pwd_mkdb /etc/master.passwd'
once you've finished if you went the edit-the-file-directly route.)

There are a bunch of fields, seperated by colons.  Below is an example:

root:*:0:0::0:0:Charlie &,,,:/root:/bin/csh

1) Username--this must be unique

2) Encrypted passwd (probably an '*' for most entries).  Leave this blank
for now (no white space).

3) User ID # - this must be a unique number

4) Group #.  You'll probably find that making yourself a 'wheel' member is
most useful.  The number for wheel is 0.

5) Class--you can just leave this blank.

6 & 7) I forget exactly what these are, but I believe they're not really
used by the system.  Enter Zeros.

[A response by "Michael G. Schabert" <mikeride@prez.buf.servtech.com>:
	"Actually, they're used by the system to tell the user to
	chnge his/her password and to expire the user entirely."



8) Your personal name.  Just fill that in.  Ignore the '&,,,,' for now.
The technical name for this part is the 'gecos field'.

9) Home directory.  You should create a folder for yourself and list that
here.  (After doing so, don't forget to use 'chown' to change the ownership
of the folder--so that you own it).  And DON'T use a trailing slash (ie-
say /root and NOT /root/).

10) Path of the shell you will use.  I used /bin/csh. [currently /bin/tcsh.
A nice improvement.  I believe tcsh is in with the packages...]

One thing you might find helpful...position your entry in the file so that
the user ID you assign yourself falls in ascending numerical order,
relative to the other User ID#s.  In vi, postion the cursor where you'd
like to insert the line, press ESC to make sure you're in command mode and
then type a capital O.

[Addendum: Then again, you could always just use 'sort' to do that..]


After you've finished with the password file, edit /etc/groups.  Find the
line that begins with 'wheel'.  After the last entry on the line add a
comma and your username (no white space).  You may also wish to add
yourself to operator as well.  (IIRC, master.passwd only contains your
primary group association.  Leave that as wheel (Group # 0) But it is okay
to list yourself several times in /etc/groups).  Adding yourself to
"operator" isn't a bad idea.

Next, a few files to have in your home directory:

.login
.chsrc (or .profile is you're using ksh)
You should find copies of this in either / or /root.  Just copy them into
your directory.  (Don't forget to use 'chown' to change the ownship of
these after copying).

.login--commands that are executed each time you log in.
.cshrc--commands executed each time your shell starts up.

These set user environment, create command line aliases, etc.

(Format for chown is 'chown <userid to change ownership to> <filename>').

Then try to log in as yourself.  Lastly, once you've logged in as yourself,
you may want to use 'chfn' (change finger information) to add your personal
info and 'passwd' to give yourself as password.

Again, this is being rattled off from memory....  Please double check what
I've said about the formatting of password files with what's contained in
passwd(5).

A fairly inexpensive book that helped me out tons (please don't laugh) was
"Teach Yourself Unix in 24 hours", published by SAMS.  It breaks the basics
down into a bunch of 1 hour lessons--it's very approachable, and I'd
reccomend it hightly to the beginner.  On the back cover, it says it has a
website http://www.intuitive.com/tyu24.  Haven't looked at that,
though....just bought the book.  [It's not to bad from the 'user end'.  A
really good book on admin?
"The Unix Systems Administrators Guide" by Nemeth, Snyder, Seebass, et al.
Not cheap, but extremely useful, IMHO]  Web site at http://www.admin.com

Other relevant man pages-- csh, and a few that come up when you type
'apropos group'.

Good luck.


And some other additions by "Michael G. Schabert"
<mikeride@prez.buf.servtech.com>

You need to use passwd to change your password. chpass is another name for
chfn, which is another name for chsh. I never even knew that such a beast
existed. Basically, it's a prettified way to change the vipw info for
already-existing users. When invoked by "regular" users, it'll only show
items which they can change. When invoked by root, then it shows every
field in the passwd file along with a name/explanation. Very nice. A nice
part is that it lists the comma-separated GECOS fields as separate lines
with an explanaion for each. Here's what it looks like for me when invoked
as me:

#Changing user database information for mikeride.
Shell: /bin/csh
Full Name: Michael G. Schabert
Location:
Office Phone: 635-9729
Home Phone: 634-3560


Here's what it looks like when invoked on mikeride by root: (passwd entry
blanked by hand by me...it shows up when invoked)

#Changing user database information for mikeride.
Login: mikeride
Password: <deleted encrypted passwd>
Uid [#]: 100
Gid [# or name]: 0
Change [month day year]:
Expire [month day year]:
Class:
Home directory: /root
Shell: /bin/csh
Full Name: Michael G. Schabert
Location:
Office Phone: 635-9729
Home Phone: 634-3560


I was lazy & just use root as my personal home directory, since I "play"
root, too. Made it easier than having to synch changes to either directory
to keep a consistent environment.

Also, it's nice to know that if you prefer a different editor to vi, all
you have to do is set it in your editor environment variable and that
editor will be used for invokations of vipw. Personally, I use pico, so
vipw, chpass, chfn, chsh all come up in pico.

>I remeber encountering the vipw error you mention. I believe I got around
>that by logging in as root, and using the command 'chfn' to change roots
>finger information (root is line 1 of the master.passwd file).  Then,
>'pwd_mkdb /etc/master.passwd' to rebuild the password database files.

This last part is unnecessary. vipw, chfn, chsh, chpass will all invoke the
pwd_mkdb when they're saved.



Steve Revilak
revilak@umbsky.cc.umb.edu