On 16 Nov 2008 at 10:55, Don Jackson wrote: > My system installation script (similar to install.site, run right after > the system was installed, and before first boot) attempts to configure a > user account using sometime pretty much like this: > > /usr/sbin/useradd -mv -b /home -c "name of user" -u 2002 -g wheel -s > /bin/ksh -p 'encrypted-password' foo > > When I did this, it created the user, but did not add the user to the > group wheel. > > Based on the man page, I was expecting the -g option to do so: > > useradd -D [-b base-dir] [-e expiry-time] [-f inactive-time] > [-g gid | name | =uid] [-k skel-dir] [-L login-class] > [-r low..high] [-s shell] > useradd [-mov] [-b base-dir] [-c comment] [-d home-dir] [-e > expiry-time] > [-f inactive-time] [-G secondary-group[,group,...]] > [-g gid | name | =uid] [-k skel-dir] [-L login-class] > [-p password] [-r low..high] [-s shell] [-u uid] user > > -g gid | groupname | =uid > sets the default group for new users. > > But it didn't, the user was created with gid 0. > > When I changed the above command to use -G instead of -g, it worked. > Why?
Because the -g options sets the user's primary gid and wheel=0, whereas -G adds supplemental groups which manifests in the group file as having the user "added to group". > Am I just not understanding the documentation for useradd? Yes ;-)