[luau] adding new users

Nakashima pnakashi at k12.hi.us
Thu Sep 18 10:05:01 PDT 2003


Thanks Keith!
The script works perfectly now :^)

--

 Peter Nakashima
 Computer Teacher
 Liholiho Elementary

--

On Wed, 17 Sep 2003, Keith wrote:

> First, if /bin/bash is available, use it.  It is much more powerful than
> traditional Bourne shell.  Even if /bin/sh is a symlink to /bin/bash and
> you execute /bin/sh it will try to mimic "historical versions of sh".
> This is explained in the bash man page in the INVOCATION section.
>
> Secondly, as a point of shell programming style, use lowercase variable
> names.  Uppercase names are typically used for environment variables
> (the ones you see when you type 'env' or 'set' at the bash shell
> prompt).  In the case of your script, you are reading in $GROUPS which
> is used by bash in the environment and is subsequently overwritten in
> the context of your script.
>
> Thirdly, I must ask what distro your LTSP clients are based off of.  If
> it is RH (and I assume it is because RH added the -f flag to groupadd;
> -f is NOT a standard groupadd flag) then you must be alerted to the fact
> that RH's implementation of 'useradd' will create a new group ID (gid)
> with the same name as the new user to be added and will make this new
> gid the primary group ID of the new user *by default*.  Again, this is a
> non-standard behavior (RH likes these things).  So, if you add a user
> 'joe' with useradd, 'joe' will have a new group called 'joe' created and
> the user 'joe' will have a primary group of 'joe'.  What this means for
> you is that you do NOT need to call groupadd prior to or after useradd
> if you plan on putting each user in his/her own primary group with the
> same name as his/her username.  It will be done for you automagically by
> RH's useradd.  Your script could be reduced to this:
>
> #!/bin/bash
> echo "User name in lowercase please:"
> read username
> echo "Comma separated list of SUPPLEMENTAL groups (NOT primary group):"
> read groups
> useradd -G"$groups" -m "$username"
> # and so on...
>
> Also note that if some user 'foo' has a primary group ID of 'bar', this
> is not reflected in /etc/group, i.e., you will not see user 'foo' on
> the line for group 'bar' in /etc/group.  Primary group IDs are stored
> for each user in /etc/passwd and are the 4th field (the 3rd field is the
> user ID).




More information about the LUAU mailing list