Manage Linux Group Using gpasswd Command

Posted on : March 14, 2013 , Last Updated on : November 23, 2013 By
| 1 Reply More

The gpasswd command (As defined in the man page) is used to administer /etc/group, and /etc/gshadow. Every group can have administrators, members and a password.

Command Options

-a, --add user Add the user to the named group.
-d, --delete user Remove the user from the named group.
-A, --administrators user,... Set the list of administrative users.
-M, --members user,... Set the list of group members.

gpasswd examples

Let us assume that we have a group named sales and three users user1,user2,user3.

Add User

To add user1 to sales group

gpasswd -a user1 sales

Add multiple user

To add multiple users to sales group

gpasswd -M user1,user2,user3 sales

Remove user

To remove user2 from sales group

gpasswd -d user2 sales

How to set a user as group administrator

gpasswd -A user group

or

gpasswd -A user1,user2 sales

Example :

gpasswd -A nixsavy linuxgroup

Set password for group

$ gpasswd linuxgroup

Changing the password for group linuxgroup

New Password:

Re-enter new password:

Browse Linux commands

Filed Under : HOWTOS, LINUX COMMANDS

Free Linux Ebook to Download

Comments (1)

Trackback URL | Comments RSS Feed

  1. The example for -M above implies adding user1,user2,user3 in addition to users already there.
    The man pages for gpasswd clearly state that option -M is to "Set the list of group members."
    This will destroy any existing set of members, so therefore is not an implicit "add" unless the group was empty to begin with.

Leave a Reply

All comments are subject to moderation.