gpasswd
gpasswd
The gpasswd
command in Linux is used to manage group membership. It is a very useful command for adding and removing users from groups, and for changing the password of a group.
The gpasswd
command takes the following arguments:
group
: The name of the group to manage.options
: Optional arguments that control the behavior ofgpasswd
.username
: The username of the user to add or remove from the group.new_password
: The new password for the group.
The following are some of the most common options for the gpasswd
command:
-a
: Adds the specified user to the group.-d
: Removes the specified user from the group.-R
: Changes the password of the group for all users in the group.-M
: Changes the password of the group for the specified user.
For example, the following command will add the user johndoe
to the group wheel
:
gpasswd -a johndoe wheel
The gpasswd
command is a very useful command for managing group membership. It is a valuable tool for anyone who needs to add or remove users from groups, and for changing the password of a group.
Here are some additional things to keep in mind about gpasswd
:
The
gpasswd
command must be run as a user who has permission to manage group membership.The
gpasswd
command can be used to manage any group on the system.The
gpasswd
command can be used to change the password of a group even if the group does not have a password.
Here are some examples of how to use gpasswd
:
To add the user
johndoe
to the groupwheel
:
gpasswd -a johndoe wheel
To remove the user
johndoe
from the groupwheel
:
gpasswd -d johndoe wheel
To change the password of the group
wheel
for all users in the group:
gpasswd -R wheel
To change the password of the group
wheel
for the userjohndoe
:
gpasswd -M wheel johndoe
The gpasswd
command is a powerful and versatile tool that can be used to manage group membership. It is a valuable tool for anyone who needs to add or remove users from groups, and for changing the password of a group.
help
Usage: gpasswd [option] GROUP
Options:
-a, --add USER add USER to GROUP
-d, --delete USER remove USER from GROUP
-h, --help display this help message and exit
-Q, --root CHROOT_DIR directory to chroot into
-r, --remove-password remove the GROUP's password
-R, --restrict restrict access to GROUP to its members
-M, --members USER,... set the list of members of GROUP
--extrausers use the extra users database
-A, --administrators ADMIN,...
set the list of administrators for GROUP
Except for the -A and -M options, the options cannot be combined.
Last updated