Forrest logo
back to the gpasswd tool

gpasswd:tldr:c7088

gpasswd: Define group administrators.
$ sudo gpasswd -A ${user1,user2} ${group}
try on your machine

This command is used to add multiple users to a specific group using the "gpasswd" command with administrative privileges (via "sudo").

Here's a breakdown of the command:

  • "sudo": It stands for "Super User Do," and it allows users with appropriate permissions to run commands with administrative privileges. When using "sudo," the user will need to provide their password to confirm their identity.

  • "gpasswd": It is a command-line utility used to manage group passwords in Linux systems. In this case, it is used to add users to a specific group.

  • "-A": It is an option or flag used with the "gpasswd" command. The "-A" option is used to add users to a group.

  • "${user1,user2}": This is a placeholder or variable that should be replaced with the actual usernames of the users to be added to the group. The usernames are separated by a comma without any spaces.

  • "${group}": This is another placeholder or variable that should be replaced with the name of the group to which the users will be added.

By executing this command with the appropriate values, the users specified in the "${user1,user2}" variable will be added to the specified group (${group}).

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the gpasswd tool