4

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?

  • 4
    If users are added using adduser, doesn't the default /etc/adduser.conf do this already? (via the EXTRA_GROUPS and ADD_EXTRA_GROUPS entries) – steeldriver Oct 8 '17 at 21:55
6

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.