# How to Automatically Add New Users to Custom Groups

**URL:** <https://forums.rockylinux.org/t/how-to-automatically-add-new-users-to-custom-groups/10500>\
**Category:** Rocky Linux Help & Support\
**Created:** [June 29, 2023, 5:05pm UTC](https://forums.rockylinux.org/t/how-to-automatically-add-new-users-to-custom-groups/10500 "2023-06-29T17:05:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![burkettlabs](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/burkettlabs/32/3256_2.png) [@burkettlabs](https://forums.rockylinux.org/u/burkettlabs)\
**Post date:** [June 29, 2023, 5:05pm UTC](https://forums.rockylinux.org/t/how-to-automatically-add-new-users-to-custom-groups/10500/1 "2023-06-29T17:05:50Z")

</div>

Is there a way in Rocky/RHEL/CentOS to automatically add new users to a custom groups?  
Ubuntu has the /`etc/adduser.conf` file that can do this. I think it might be possible with `/etc/default/useradd` but that is unclear to me.

---

<div class="post-metadata">

**Author:** ![burkettlabs](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/burkettlabs/32/3256_2.png) [@burkettlabs](https://forums.rockylinux.org/u/burkettlabs)\
**Post date:** [June 30, 2023, 12:10am UTC](https://forums.rockylinux.org/t/how-to-automatically-add-new-users-to-custom-groups/10500/2 "2023-06-30T00:10:13Z")

</div>

I asked this on the r/linuxadmin subreddit as well and no one knew of a native way to do this.

---

<div class="post-metadata">

**Author:** ![Cphusion](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/cphusion/32/3235_2.png) [@Cphusion](https://forums.rockylinux.org/u/Cphusion)\
**Post date:** [June 30, 2023, 3:01pm UTC](https://forums.rockylinux.org/t/how-to-automatically-add-new-users-to-custom-groups/10500/3 "2023-06-30T15:01:38Z")

</div>

It does look like because in the man page of useradd I see this.

> /etc/default/useradd  
> Default values for account creation.  
> -g, --gid GROUP
> 
> The group name or ID for a new user’s initial group (when the -N/–no-user-group is used or when the USERGROUPS\_ENAB variable is set to no in /etc/login.defs). The named group must exist, and a numerical group ID must have an existing entry.
> 
> This option sets the GROUP variable in /etc/default/useradd.

I have never used it though since I use Ansible for usermanagement now days.

---

<div class="post-metadata">

**Author:** ![burkettlabs](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/burkettlabs/32/3256_2.png) [@burkettlabs](https://forums.rockylinux.org/u/burkettlabs)\
**Post date:** [June 30, 2023, 4:06pm UTC](https://forums.rockylinux.org/t/how-to-automatically-add-new-users-to-custom-groups/10500/4 "2023-06-30T16:06:21Z")

</div>

Thank you. I saw that as well but we want to still create the user-group. We decided we are just going to have to enforce Ansible usage. .
