Groups

How to add two user in a group in linux ?

To add two users to a group in Linux, you can use the usermod command with the -aG option followed by the name of the group.

Here's an example command:

sudo usermod -aG groupname user1 user2

In this command, replace groupname with the name of the group you want to add the users to, and replace user1 and user2 with the names of the users you want to add.

The usermod command modifies the user's account settings, and the -aG option specifies that you want to append the group to the user's list of supplementary groups. If the group doesn't exist, the command will create it.

After running this command, the two users will be added to the specified group and will have the group's permissions and access. You may need to log out and log back in for the changes to take effect. You can verify the group membership of a user by running the groups command followed by the username:

groups username

This command will display a list of groups that the user belongs to, including the newly added group.