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.
-
On what Unix variant or distribution? Different ones have different commands to manage users and groups. – Gilles 'SO- stop being evil' May 18 '20 at 17:58
-
@Gilles'SO-stopbeingevil' sorry, edited question. It's about linux (Debian) – user6329530 May 18 '20 at 18:01
2 Answers
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.

- 556
- 2
- 10
-
No, it's supposed extra groups by default for all new users. Your first option answers the question. – user6329530 May 19 '20 at 05:22
# 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.

- 6,575