add user to multiple groups ubuntu

To add a user to multiple groups in Ubuntu using the command line, you can follow these steps:

  1. Open a terminal window.
  2. Use the sudo usermod command to modify the user's group membership. The basic syntax is as follows:

sudo usermod -aG group1,group2,group3 username

Replace group1, group2, and group3 with the actual group names you want to add the user to, and replace username with the actual username.

For example, if you want to add the user "john" to the groups "admin", "developers", and "staff", you would run the following command:

sudo usermod -aG admin,developers,staff john

  1. After executing the command, the user will be added to the specified groups. You can verify the changes by using the groups command followed by the username:

groups username

This will display a list of groups the user belongs to.

That's it! The user will now be a member of multiple groups in Ubuntu.