Once you have groups in place, you can add existing users as well as new users to that group. All access rights and permissions assigned to the group will be automatically available to all the members of the group.
You will need super user or root privileges to add a group member to the Ubuntu server.
Follow these steps to add group members:
adduser
command with two non-option arguments:$ sudo adduser john guest
addgroup
with root privileges.As mentioned previously, you can use the adduser
command to add an existing user to an existing group. Here, we have passed two non-option arguments:
Alternatively, you can use the command usermod
to modify the group assigned to the user:
$ sudo usermod -g <group> <username>
To add a user to multiple groups, use the following command:
$ sudo usermod -a -G <group1>,<group2>,<group3> <username>
This will add <username>
to <group1>
, <group2>
, and <group3>
. Without flag –a
, any previously assigned groups will be replaced with new groups.