Forrest logo
back to the gpasswd tool

gpasswd:tldr:554c2

gpasswd: Set the list of group members.
$ sudo gpasswd -M ${user1,user2} ${group}
try on your machine

The command sudo gpasswd -M ${user1,user2} ${group} is being executed with administrative privileges (using sudo). It modifies the group membership (-M) of multiple users (${user1,user2}) and assigns them to a specific group (${group}).

Here's a breakdown of the command:

  • sudo: This command allows a user with administrative (root) privileges to execute the following command.
  • gpasswd: This is a command used to manage the group passwords and membership in Linux.
  • -M ${user1,user2}: The -M flag specifies a comma-separated list of users that should be added to or removed from the group. In this case, ${user1,user2} represents multiple user names or variable values.
  • ${group}: This is the name of the group where the specified users will be added or removed. It is a variable value or a specific group name.

By executing this command, the group membership of user1 and user2 will be modified to include them in the ${group} group specified.

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