To add users to a group in Linux, you can use the usermod command. Here’s how to do it:
-
Open a terminal.
-
Use the following command to add a user to a group:
sudo usermod -aG groupname usernameReplace
groupnamewith the name of the group you want to add the user to, andusernamewith the name of the user.For example, to add a user named
johnto a group calledsales, you would run:sudo usermod -aG sales john -
Verify the change by checking the groups the user belongs to:
groups usernameFor example:
groups john
This command will display all the groups that john is a member of, confirming that the user has been successfully added to the specified group.
