Forrest logo
back to the usermod tool

usermod:tldr:873e4

usermod: Add a user to supplementary groups (mind the lack of whitespace).
$ sudo usermod --append --groups ${group1,group2,---} ${username}
try on your machine

This command modifies a user's group membership using the usermod command in Linux. Here is a breakdown of the command:

  • sudo: The sudo command is used to execute the subsequent command with administrative privileges. It allows the user to run commands as a superuser or another user.
  • usermod: This command is used to modify user account details in Linux.
  • --append: This option is used to append the user to additional groups instead of replacing their existing group membership.
  • --groups ${group1,group2,---}: This option specifies the groups to which the user will be added. You need to replace ${group1,group2,---} with the actual names of the groups, separated by commas.
  • ${username}: This is the username of the user whose group membership you want to modify. You need to replace ${username} with the actual username.

In summary, this command adds the specified user (${username}) to the additional groups (${group1,group2,---}) by appending them to the user's existing group membership. This is done using the usermod command with administrative privileges (sudo).

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 usermod tool