[K12OSN] creating accounts

Terrell Prudé, Jr. microman at cmosnetworks.com
Fri Sep 30 03:25:44 UTC 2005


No, there isn't.  I never use the GUI on any GNU/Linux or BSD box to
administer user accounts.  I would make three modifications right away
to your script, though.

1.)  It should use the uppercase "G" parameter instead of the lowercase
"g" parameter.  Red Hat-based distros, including Fedora Core, will by
default put the userID in a "private group" with the same name as the
userID.  Once I got used to it, I realized that this is a Good Thing
(TM) for both security and future maintenance purposes.  For example,
next year, when Kayla Abad and her classmates go to Grade 4, you don't
have to touch every userID in /etc/passwd (DANGEROUS!!!), but rather
just rename the group "Grade3" to "Grade4" in /etc/group (MUCH safer and
MUCH easier).

2.)  The "p" parameter needs to come before the userID.  You have it
afterward, so you may well be making a userID of "kabad -p kaab", which,
I'm fairly confident, was not your intention.  The other possibility is
that you got a parsing error.  I'd have to try it out on a test box to
make sure which possibility actually takes place.  You might want to
look at your /etc/passwd file to find out what's going on.

3.)  The "m" parameter should be used instead of the "d" parameter.  The
"d" parameter, I've learned, works if the specified directory is already
created.  But what if it isn't?  The "m" parameter handles this.  If the
specified home directory (in your example, /home/kabad) doesn't already
exist, then useradd will go ahead and make it for you.  If it does
exist, useradd will simply use the existing one.  Yes, there are in fact
special cases in which the "d" parameter would come in handy.  But I
think you really want "m".

Anyway, your useradd command to create the users should look like this:

useradd -c "Kayla Abad" -m /home/kabad -G Grade3 -p kaab kabad

I notice that you're generating the userID, home directory, and password
from differing parts of the student's first and last name.  If you have
a flat text file with each child's first and last name, you actually can
get fancy and generate the userIDs, home directories, and passwords in a
shell script as well.  See the Advanced BASH Scripting Guide
(http://www.tldp.org) for more details.

--TP


On Thu, 2005-09-29 at 19:43 -0700, gKw-X wrote:

> I went in today and ran my script. It appeared to create all of the 
> accounts and groups properly - I went into the users and groups manager 
> ui and they were all there. However, I couldn't log in to them from 
> client machines. If I manually create an account through the ui, I can 
> log in to it, but if I use the useradd command I can't. Is there some 
> extra step to notify K12LTSP about the new accounts?
> 
> Samps wrote:
> > gKw-X wrote:
> > 
> >> I need to create a large number of accounts. I've whipped up a program 
> >> to generate a script from a text list of students. What it generates 
> >> looks like this:
> >>
> >> groupadd "Grade3"
> >> groupadd "Grade2"
> >> groupadd "Grade1"
> >> groupadd "Grade6"
> >> groupadd "Grade7"
> >> groupadd "Grade4"
> >> groupadd "GradeK"
> >> groupadd "Grade5"
> >> useradd -c "Kayla Abad" -d /home/kabad -g Grade3 kabad -p kaab
> >>
> >> Etc, one useradd line for each student. Does that look correct? I'm 
> >> still new to linux, how can I run this script?
> >>
> >> _______________________________________________
> >> K12OSN mailing list
> >> K12OSN at redhat.com
> >> https://www.redhat.com/mailman/listinfo/k12osn
> >> For more info see <http://www.k12os.org>
> >>
> >>
> >>
> >>
> > Add a line at the top of your script to tell it where to find its 
> > command interpreter:
> > 
> > #! /bin/bash
> > groupadd "Grade3"
> > groupadd "Grade2"
> > groupadd "Grade1"
> > groupadd "Grade6"
> > 
> > (you can find the name of your shell (/bin/bash) by typing echo $SHELL 
> > on a commandline)
> > 
> > save your script and make it executable by changing its attributes:
> > 
> > chmod +x yourscript
> > 
> > or
> > 
> > chmod +x /path/to/yourscript
> > 
> > if you're not "standing right next to it"
> > 
> > 
> > run it by typing :
> > 
> > /path/to/yourscript
> > 
> > or
> > 
> > ./yourscript
> > 
> > if you're able to "see" it from where you are...
> > 
> > cheers
> > Samps
> > 
> > _______________________________________________
> > K12OSN mailing list
> > K12OSN at redhat.com
> > https://www.redhat.com/mailman/listinfo/k12osn
> > For more info see <http://www.k12os.org>
> > 
> > 
> 
> _______________________________________________
> K12OSN mailing list
> K12OSN at redhat.com
> https://www.redhat.com/mailman/listinfo/k12osn
> For more info see <http://www.k12os.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/k12osn/attachments/20050929/2161fb93/attachment.htm>


More information about the K12OSN mailing list