To add a user to a group in Linux, you can use the usermod command. Here are the steps:
-
Open a terminal.
-
Use the following command to add a user to a group. Replace
usernamewith the name of the user andgroupnamewith the name of the group:sudo usermod -aG groupname usernameThe
-aGoption means "append to Group," which adds the user to the specified group without removing them from any other groups. -
To verify that the user has been added to the group, you can check the groups they belong to with:
groups username
This will display a list of all groups that the user is a member of, including the newly added group.
