Add a User to a Group on Linux

To add a user to a group on Linux, follow these steps:

  1. Open the terminal: Open a terminal window on your Linux machine.
  2. Check the current groups: Type in the command “groups” to check the current groups that the user belongs to.
  3. Check the available groups: Type in the command “cat /etc/group” to see a list of all the available groups on your system.
  4. Add user to a group: Type in the command “sudo usermod -a -G <group-name> <username>” to add the user to a group. Replace <group-name> with the name of the group you want to add the user to, and <username> with the name of the user you want to add.
  5. Verify the user’s groups: Type in the command “groups <username>” to verify that the user has been added to the group.
  6. Logout and login: To apply the changes, the user needs to log out and log back in.

By following these steps, you can easily add a user to a group on Linux. Note that you need to have sudo access to add a user to a group.