Skip to content

How to Add a Group to User

  • by

Let's print current id of the user.

[root@primary01 ~]# id oracle
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba)

In this case, we would like to add a new group called oper to the user.

The very first step, we create the group.

[root@primary01 ~]# groupadd -g 54323 oper

Then we add the group to the secondary group of the user.

[root@primary01 ~]# usermod -a -G oper oracle
[root@primary01 ~]# id oracle
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper)

Basically, an user can have more than one secondary groups, but only one primary group. That is to say, if you want the new group to be the primary one, the only thing you can do is to replace the primary group of the user.

Leave a Reply

Your email address will not be published.