When a new user is created, they are assigned to a set of default groups. How do I change which default groups are assigned?
When a new user is created, they are assigned to a set of default groups. How do I change which default groups are assigned?
That can change according to the way you are creating the new user.
If you are using
useradd
you can either specify the-G
option or use that dirty (very dirty) workaround : rewriting a useradd script.There is maybe a possibility to specify multiple default groups in /etc/default/useradd but I could not find anything in the man or online in the couple of minutes of research I did. So if you really need to do it you can :
and now recreate /usr/bin/useradd with the following content
Now make this executable chmod +x /usr/bin/useradd
And you should be ready to go.
It may happen that the useradd command is not located in /usr/bin . You can find it using
whereis useradd
Once again, this is a dirty hack that will be overwritten by an update. Be careful when doing something like this.
Assuming you are using the
adduser
command to add new users:Open /etc/adduser.conf in your text editor of choice and scroll down until you see #EXTRA_GROUPS.
Uncomment this and the #ADD_EXTRA_GROUPS line beneath it.
Set the value of EXTRA_GROUPS to whatever you would like the groups to be for new users aside from their own named group.
Save and start creating new users.