gpasswd

Linux · Users and permissions · reference only

What it does

Manages groups: adds or removes members, sets the full member list or names group administrators.

Syntax

gpasswd [opciones] grupo

Options and parameters

  • -a usuario

    Adds the user to the group.

  • -d usuario

    Removes the user from the group.

  • -M u1,u2

    Sets the full member list, replacing the previous one.

  • -A u1,u2

    Sets the list of group administrators.

  • -r

    Removes the group password.

  • -R

    Prevents anyone from joining the group with newgrp, even with the password.

Usage examples

  • sudo gpasswd -a ana devs

    Adds ana to the devs group.

  • sudo gpasswd -d ana devs

    Removes ana from the devs group.

  • sudo gpasswd -M ana,luis devs

    Makes ana and luis the only members of devs.

  • groups ana

    Checks which groups ana belongs to now.

Notes and common mistakes

  • The change does not affect open sessions: the user must log out and back in, or use newgrp.
  • -M replaces the whole member list; if you only want to add one, use -a.

Related commands