5

When I add an user under Debian Linux, I want to set her default group to a list of specific groups so she will get added to these groups when creating her account.

2 Answers2

4

Use the --add_extra_groups option to the adduser command.

If you want the extra groups to be the same for all or most new users, as I interpret your question, you just need to define the EXTRA_GROUPS setting in /etc/adduser.conf. If you OTOH need a special case for a particular new user, create a new config file, say /root/adduser.conf, by copying /etc/adduser.conf, add the EXTRA_GROUPS setting to the new file, and run adduser with the --conf and --add_extra_groups options.

q.undertow
  • 556
  • 2
  • 10
2
# within the file     /etc/default/useradd

GROUP=100

change the id there, 100 corresponds to users (in RHEL/CentOS anyway).

With that set, a simple

adduser <account name>  --comment <first\ Last_name>   --uid <number>

will by default create the given user account having the default group of GROUP

modify that user account to have additional groups by doing

usermod  <acount name>  -G  <group name>

example:   usermod   ron  -G wheel
           usermod   ron  -G thisgroup,thatgroup,and,so,on

to manually re-set an account to have a different default group it is the lowercase g option like this

usermod <account name>  -g users

If you want to create new groups, unless you just want to manually edit /etc/group it can be done via

groupadd --gid  <new group id>  <new group name>

Within /etc/login.defs is where GID_MIN and GID_MAX is set, change those to suit your needs if necessary.

ron
  • 6,575