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 usuarioAdds the user to the group.
-d usuarioRemoves the user from the group.
-M u1,u2Sets the full member list, replacing the previous one.
-A u1,u2Sets the list of group administrators.
-rRemoves the group password.
-RPrevents anyone from joining the group with newgrp, even with the password.
Usage examples
sudo gpasswd -a ana devsAdds ana to the devs group.
sudo gpasswd -d ana devsRemoves ana from the devs group.
sudo gpasswd -M ana,luis devsMakes ana and luis the only members of devs.
groups anaChecks 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.