Automatically add users to groups
5,076
This can be achieved using the /etc/adduser.conf
file in the following way. Edit the file:
sudo nano /etc/adduser.conf
In change these lines:
# Set this if you want the --add_extra_groups option to adduser to add
# new users to other groups.
# This is the list of groups that new non-system users will be added to
# Default:
#EXTRA_GROUPS="dialout cdrom floppy audio video plugdev users"
# If ADD_EXTRA_GROUPS is set to something non-zero, the EXTRA_GROUPS
# option above will be default behavior for adding new, non-system users
#ADD_EXTRA_GROUPS=1
To:
# Set this if you want the --add_extra_groups option to adduser to add
# new users to other groups.
# This is the list of groups that new non-system users will be added to
# Default:
EXTRA_GROUPS="audio"
# If ADD_EXTRA_GROUPS is set to something non-zero, the EXTRA_GROUPS
# option above will be default behavior for adding new, non-system users
ADD_EXTRA_GROUPS=1
Now whenever you use adduser
the user will also be added to the audio group. Please note that that group must exist. SO first create the group if it doesn't exist then add it to the /etc/adduser.conf
.
You can control this behaviour by setting
ADD_EXTRA_GROUPS=1
to
ADD_EXTRA_GROUPS=0
This will disable this behaviour, so one can always switch it on/off
.
Related videos on Youtube
Author by
Giovanni Caligaris
Updated on September 18, 2022Comments
-
Giovanni Caligaris over 1 year
I am creating a custom iso for a friend.
How can I add all users and future new users to the audio (or any other) group?
If I want to add a single user I would run
sudo adduser $USER audio
Is there a way of doing automatically every time a new user account is created?
-
steeldriver over 6 yearsIf users are added using
adduser
, doesn't the default/etc/adduser.conf
do this already? (via theEXTRA_GROUPS
andADD_EXTRA_GROUPS
entries)
-