gpasswd – Workgroup file management tool under Linux

The gpasswd command is a Linux utility that is used to manage the group password file, /etc/group. The command is used to add and remove users from a group, set a new password for a group, or delete a group entirely. This command is typically used in conjunction with other Linux commands to manage user and group permissions and access.

Overview

The gpasswd command is used to manage group passwords and membership. The syntax for the gpasswd command is as follows:

gpasswd [options] [group]

Where group is the name of the group you want to manage. If no options are specified, the gpasswd command will prompt you for a password for the group.

Adding users to a group

To add a user to a group, use the -a option, followed by the user’s username and the name of the group:

gpasswd -a username group

For example, to add the user jdoe to the group developers, you would run the following command:

gpasswd -a jdoe developers

Removing users from a group

To remove a user from a group, use the -d option, followed by the user’s username and the name of the group:

gpasswd -d username group

For example, to remove the user jdoe from the group developers, you would run the following command:

gpasswd -d jdoe developers

Setting a new group password

To set a new password for a group, use the -r option, followed by the name of the group:

gpasswd -r group

This will prompt you to enter a new password for the group.

Deleting a group

To delete a group, use the -x option, followed by the name of the group:

gpasswd -x group

This will delete the group from the system, along with any users that were members of the group.

Options

The following table lists the available options for the gpasswd command:

Option Description
-a Add a user to a group
-d Remove a user from a group
-r Set a new password for a group
-x Delete a group

Troubleshooting tips

  • If you receive an error message that says “permission denied,” make sure you have sufficient privileges to manage groups on the system.
  • If you receive an error message that says “group does not exist,” make sure you have spelled the group name correctly and that the group exists on the system.

Notes

  • The gpasswd command is typically used in conjunction with other Linux commands to manage user and group permissions and access.
  • The gpasswd command is only available on Linux systems.