LinuxCommandLibrary

gpasswd

TLDR

Define group administrators

$ sudo gpasswd -A [user1,user2] [group]
copy
Set the list of group members
$ sudo gpasswd -M [user1,user2] [group]
copy
Create a password for the named group
$ gpasswd [group]
copy
Add a user to the named group
$ gpasswd -a [user] [group]
copy
Remove a user from the named group
$ gpasswd -d [user] [group]
copy

SYNOPSIS

gpasswd [option] group

DESCRIPTION

gpasswd administers /etc/group and /etc/gshadow files. It's used to add and remove users from groups, set group administrators, and manage group passwords.
Group administrators (set with -A) can add or remove members without root privileges. This delegates group management to trusted users.
Group passwords (rarely used) allow non-members to temporarily join a group using the newgrp command with the password. This is generally considered less secure than proper group membership.

PARAMETERS

-a, --add USER

Add user to the group
-d, --delete USER
Remove user from the group
-A, --administrators USER,...
Set list of group administrators
-M, --members USER,...
Set list of group members (replaces existing)
-r, --remove-password
Remove group password
-R, --restrict
Restrict access to group (only members can use newgrp)

CAVEATS

The -M option replaces all group members, not appends. Use -a and -d for incremental changes. Group password usage is discouraged in favor of proper membership management. Changes take effect on next login.

HISTORY

gpasswd is part of the shadow-utils package, which provides the shadow password suite for Unix systems. The shadow system was developed in the 1980s to improve password security by moving password hashes from the world-readable /etc/passwd to the restricted /etc/shadow file.

SEE ALSO

groupadd(8), groupmod(8), usermod(8), newgrp(1)

Copied to clipboard