How to add a user to a group?

To add a user to a group in Linux, you can use the usermod command. Here are the steps:

  1. Open a terminal.

  2. Use the following command to add a user to a group. Replace username with the name of the user and groupname with the name of the group:

    sudo usermod -aG groupname username

    The -aG option means "append to Group," which adds the user to the specified group without removing them from any other groups.

  3. 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.

0 Comments

no data
Be the first to share your comment!