How to add users to a group in Linux?
In Linux, the usermod command can be used to add a user to a specific group.
The format of the command is: usermod -aG
For example, to add the user “john” to the group “developers”, you can use the following command:
sudo usermod -aG developers john
Please note that using the -a option is to prevent users from being removed from other groups. Without the -a option, users will only be added to the specified group and removed from other groups.
After adding a user to a group, you need to log in again for the changes to take effect. You can use the following command to see which groups a user belongs to:
groups <用户名>
This will list all the groups that the user belongs to.