To add a user to a group on a Linux system using the command line, you can use the usermod command.
To add the user user1 to the group group1, run the following command:
sudo usermod -a -G group1 user1
This will append the user user1 to the group1 group. The -a option tells usermod to append the user to the group, rather than replacing the user's existing group membership.
You can also use the adduser command to add a user to a group. To add the user user1 to the group group1 using adduser, run the following command:
sudo adduser user1 group1
Note that you will need to log out and log back in for the changes to take effect.