In Ubuntu Linux, you can add a user to a group using the usermod
command. Here’s an example:
- First, determine the name of the user and the group you want to add the user to. For example, let’s say the user’s name is
user1
and the group name isgroup1
. - Use the following command to add the user to the group:
sudo usermod -a -G group1 user1
The
-a
option specifies that the user should be appended to the group, and the-G
option specifies the group name. - Log out and log back in for the changes to take effect. You can also use the following command to activate the changes without logging out:
newgrp group1
- You can verify that the user has been added to the group by using the following command:
groups user1
This will list all the groups the user belongs to.