How to add users to a group?

To add users to a group in Linux, you can use the usermod command. Here’s how to do it:

  1. Open a terminal.

  2. Use the following command to add a user to a group:

    sudo usermod -aG groupname username

    Replace groupname with the name of the group you want to add the user to, and username with the name of the user.

    For example, to add a user named john to a group called sales, you would run:

    sudo usermod -aG sales john
  3. Verify the change by checking the groups the user belongs to:

    groups username

    For example:

    groups john

This command will display all the groups that john is a member of, confirming that the user has been successfully added to the specified group.

0 Comments

no data
Be the first to share your comment!