How do I 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. Run the following command to add a user to a group. Replace username with the actual username and groupname with the name of the group:

    sudo usermod -aG groupname username

    For example, to add the user john to the sales group, you would run:

    sudo usermod -aG sales john
  3. Verify the user has been added to the group by running:

    groups username

    This will display the groups that the user belongs to.

Important Notes:

  • The -a option appends the user to the group without removing them from other groups.
  • You need administrative privileges to add users to a group.
  • The user must already exist on the system.

0 Comments

no data
Be the first to share your comment!