Q. User tom is a member of a group called sales and printer. I’d like to remove tom from a group called printer without editing any user configuration text files stored at /etc/ directory?

A. /etc/groups file defines group membership for each user. usermod command has -G option to set a list of supplementary groups which the user is also a member of. Each group is separated from the next by a comma, with no intervening whitespace. If the user is currently a member of a group which is not listed, the user will be removed from the group.

Step # 1: Find out user group identity

Use id command:
# id -nG {user-name}
# id -nG tom


sales printer

Step # 2: Remove user from printer group

Use the following syntax:
# usermod -G {groupname1,groupname2,...} {username}
To keep membership for sales only group (remove user tom from printer group), enter:
# usermod -G sales tom
# id -nG tom



The following example remove user vivek from all groups except admin, audio, video and powerdev group:
# id -nG vivek

vivek adm dialout cdrom floppy audio dip video plugdev scanner netdev lpadmin powerdev admin

Modify group membership, enter:
# usermod -G admin, audio, video, powerdev vivek
# id -nG tom

Sample output:

vivek audio video powerdev admin

For more information, read usermod(8) command man page:
$ man usermod

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 21 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
21 comments… add one
  • test Mar 25, 2009 @ 15:21

    Thanks for your website.
    it’s very helpful.

  • shingai Apr 2, 2009 @ 13:42

    lets say i want to add an existing user to an existing group. when the user belongs to other groups already. what command will i use.

    using usermod-g “groupname” user will change the initial gropu of the user and delete him from another group.
    usermod -G this will lead from the user being deleted ffrom all other groups except the one sspecified.

    • ashish choudhary Feb 4, 2016 @ 20:55

      hey !! shingai

      usermod -aG {groupname1,groupname2….} username

  • kailash bhandari Apr 25, 2009 @ 18:38

    A user (pop)who is belong to SALES group. i want that pop is remove from SALES group. how can i do it. not tell me manually. i want command to remove it..

  • BAReFOOt Apr 28, 2009 @ 15:41

    In one line (and nice for scripts):
    Add a group: usermod -aG GROUP USER
    Remove a group: usermod -G $(id -nG USER| sed -e ‘s/GROUP //’ -e ‘s/ /,/g’) USER

  • ashim Jun 10, 2009 @ 5:42

    Can anyone tell me command(s) to add an user to a new group without mentioning all the groups the user previously belongs to? (I haven’t gone thru man)

  • Bhagyesh Dhamecha Jul 15, 2009 @ 10:39

    Please add me in your group and please gime update and help for any my query..


  • cheri Aug 13, 2009 @ 18:22


    I have added user to a group called sales using smbldap-usermod -G .
    How do I remove this user from the supplementary group. I was once succesful in removing the user by using the command smbldap-usermod -g . But when I give the time id -nG the supplementary group still shows up.
    Can you explain why this happens and how to overcome this problem.
    Appreciate your help


  • Mike Sep 23, 2009 @ 10:12

    to remove a user from one supplemental group only:-

    gpasswd -d USER GROUP

  • Mario Sep 23, 2009 @ 20:02

    this dint help me

    id -nG aares00
    OutPut= aaresusers rootmembers

    gpasswd -d aares00 rootmembers
    OutPut= Removing user aares00 from group rootmembers

    id -nG aares00
    OutPut= aaresusers rootmembers

    • Rajesh R Dec 6, 2011 @ 10:22

      [root@localhost ~]# gpasswd -d new tes
      Removing user new from group tes
      gpasswd: unknown member new

      while trying getting this error
      need to remove new (new-user from group- tes)

    • Deyaa Apr 28, 2012 @ 20:35

      You must log out then back in after removing a user from a group using gpasswd ;)

  • Chris Jul 17, 2010 @ 19:44

    I don’t know if it’s available from other platforms or not, but I have this command on Arch which seems more intuitive and easier to do:

    groupmems -g [group_name] -d [user_name]

    For example, if I want to remove sally from group admins:

    groupmems -g admins -d sally

  • Andrew Jul 27, 2010 @ 17:13

    lol late reply, @ ashim


  • ankit gupta Oct 9, 2010 @ 11:38

    Thank Dear

  • dario boring Feb 26, 2011 @ 11:53

    to remove all groups from user
    usermod -G “” javito

  • renato silva Mar 18, 2011 @ 12:37

    groupmod -R user group

    groupmod -A user group

    • Juan Manuel May 22, 2011 @ 18:13

      Renato, the -R argument don’t exist for groupmod command in Ubuntu. Try man groupmod.

  • Alex Dec 21, 2011 @ 16:24

    If you want to add/remove a user only to/from a single secondary group, use gpasswd command

    Following your example

    Remove tom from sales group
    gpasswd -d tom sales

    Add tom to printer group
    gpasswd -a tom printer

  • Alain Jun 8, 2016 @ 19:08

    sudo delgroup usr02 grp03 removes usr02 from grp03

  • Alain Jun 8, 2016 @ 19:14

    sudo deluser usr02 grp02

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum