Sometime in Linux command line, we need to remove Linux users from their secondary group. This is could easily achievable through usermod command.

We are trying this setup on CentOS7 latest as of now Nov 2017.

We have u1 user that has secondary group as mentioned below.First we have to find user’s secondary group.

Step#1– Find User’s group

# groups u1
u1 : u1 Sudo-admin updates
# id -nG u1
u1 Sudo-admin updates

But now we have another team working on system updates and some users need to remove from update group which has sudo rights for system update. So we need to remove user from their secondary group name updates.

Step#2–Removal of User from Group

Group list of Users
# groups u1
u1 : u1 Sudo-admin updates
Remove update Group
# usermod -G Sudo-admin u1
# groups u1
u1 : u1 Sudo-admin

Hence, With above commands we are able to remove update group from user u1 secondary group