# Default groups settings

## mbjr

Hi All,

There's one interesting behavior I noticed with my somewhat new install:

I'm adding new users and expecting behavior as per defined in /etc/default/useradd (default)

$# grep GROUP /etc/default/useradd

GROUP=100

$# grep :100: /etc/group

users::100:

$# useradd testuser

$# grep testuser /etc/passwd

testuser:x:1005:1014::/home/testuser:/bin/bash

So it seems instead of adding my user to my default "users" group I get a new group created and new users are defaulting to it.

Any ideas on what might override my /etc/default/useradd settings?

Many thanks,

----------

## Mike Hunt

You can assign a GID to the new user, for example: with the '-g users' command line option of useradd/adduser.  It can always be done later with the usermod command.

```
adduser -g users -G lp,wheel,audio,cdrom,portage,cron -m <username>
```

```
usermod -g users <username>
```

----------

## mbjr

Hello there,

Thanks for your reply.

I'm still looking for modifying the default settings. My intention is to create users with default group 'users' or any other group really.

There are two reasons for this:

a) I'm getting users to interact with a rather strict permission setting on the filesystem level but allowing them to work as a group (ie: umask 2)

b) There's group quota set and applied as default for these users.

I don't want to leave much room for error in daily standard operations if possible.

Thanks,

----------

## tox2ik

```

$ adduser  hei 

raptor: /etc/security

$ id hei 

uid=1518(hei) gid=1539(hei) groups=1539(hei)

raptor: /etc/security

$ userdel hei

$ adduser -g 100 hei 

raptor: /etc/security

$ id hei 

uid=1518(hei) gid=100(users) groups=100(users)

```

lol dude. rtfm :p

```
$ adduser -h 

adduser: invalid option -- 'h'

Usage: useradd [options] LOGIN

Options:

  -b, --base-dir BASE_DIR       base directory for the new user account

                                home directory

  -c, --comment COMMENT         set the GECOS field for the new user account

  -d, --home-dir HOME_DIR       home directory for the new user account

  -D, --defaults                print or save modified default useradd

                                configuration

  -e, --expiredate EXPIRE_DATE  set account expiration date to EXPIRE_DATE

  -f, --inactive INACTIVE       set password inactive after expiration

                                to INACTIVE

  -g, --gid GROUP               force use GROUP for the new user account

  -G, --groups GROUPS           list of supplementary groups for the new

                                user account

  -h, --help                    display this help message and exit

  -k, --skel SKEL_DIR           specify an alternative skel directory

  -K, --key KEY=VALUE           overrides /etc/login.defs defaults

  -l,                           do not add the user to the lastlog and

                                faillog databases

  -m, --create-home             create home directory for the new user

                                account

  -N, --no-user-group           do not create a group with the same name as

                                the user

  -o, --non-unique              allow create user with duplicate

                                (non-unique) UID

  -p, --password PASSWORD       use encrypted password for the new user

                                account

  -r, --system                  create a system account

  -s, --shell SHELL             the login shell for the new user account

  -u, --uid UID                 force use the UID for the new user account

  -U, --user-group              create a group with the same name as the user

```

----------

## cach0rr0

 *tox2ik wrote:*   

> 
> 
> lol dude. rtfm :p
> 
> 

 

"TFM" you just listed does not in any way answer the original poster's question. 

He knows how to specify the group on the command line

He is wondering why although useradd is set to always add to 'users' by default according to:

```

# cat /etc/default/useradd

# useradd defaults file

GROUP=100

HOME=/home

INACTIVE=-1

EXPIRE=

SHELL=/bin/bash

SKEL=/etc/skel

```

The users do not appear to  be added to the 'users' group. If useradd adheres to /etc/default/useradd, then they should be added to gid=100 regardless of whether or not he specifies a group on the command line. 

And that is the crux of the issue. We all know you can specify 'useradd -m -G users someusername', the point is avoiding having other confused admins come in and just 'useradd someusername' and end up with the newly-added user not being in the 'users' group.

----------

## cach0rr0

@ original poster:

`man useradd` shows this one which is why you see gid=1014 for the user

 *Quote:*   

> 
> 
> DESCRIPTION
> 
>        When invoked without the -D option, the useradd command creates a new user account using the values specified on the command line plus the
> ...

 

The part in bold is what's relevant

So by default whenever I add a user 'cach0rr0', there is also a group named 'cach0rr0' created.

----------

