To add a user to a group in Linux, you can use the usermod command with the -aG option. Here’s the syntax:
sudo usermod -aG groupname username
groupname: The name of the group you want to add the user to.username: The name of the user you want to add.
For example, to add a user named jack to a group called developers, you would run:
sudo usermod -aG developers jack
After running this command, you can verify that the user has been added to the group by using:
groups jack
This will list all the groups that jack belongs to, including developers.
