Skip to content
Home » DB_CREATE_ONLINE_LOG_DEST_2 » How to Change Primary Group of a User

How to Change Primary Group of a User

Change Primary Group

In our case, there's a user called oracle who has identification like following:

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

I would like to change the primary group to dba and let oinstall join the secondary group. That is to say, my purpose is to switch the places of dba and oinstall.

Assign Primary Group

Here I use -g to assign the primary group to the user.

[root@test ~]# usermod -g dba oracle
[root@test ~]# id oracle
uid=54321(oracle) gid=54322(dba) groups=54322(dba)

As you can see, the former primary group oinstall has been excluded from the user.

Add a Secondary Group

You can use -aG to add a secondary group to the user.

[root@test ~]# usermod -aG oinstall oracle
[root@test ~]# id oracle
uid=54321(oracle) gid=54322(dba) groups=54322(dba),54321(oinstall)

Now we have changed the primary group of user oracle.

Further reading: How to Change a User’s Default Shell to Bash.

Leave a Reply

Your email address will not be published. Required fields are marked *