Top community members
All Wiki Articles Create Wiki Article

Welcome to Dirask IT community! ❀ đŸ’»
We are community that shares solutions with each other.

If you think you have something to add here.

you are welcome with your fresh ideas - List Articles

Linux - add user to specific group

0 contributions
3 points

In this article, we're going to have a look at how to add user to specific group in Linux.

Simplest way is to use usermod command as super user (user with special permissions).

Quick overview:

usermod -a -G my-group-name my-user-name

Check following example to know how to do it:

1. Add user to existing group example

In this section we would like to show how add some user to avaialble group - in this example sudo group.

Note be sure you are logged-in as user with special permissions, e.g. super user / root.

  1. If you are not, login to root account with command:
    su

    It will ask you to type root password and press enter key:

    my-user-name@my-pc-name:~$ su
    Password: 
  2. Then add user to group with command:
    usermod -a -G sudo my-user-name

    Note: sudo group can be replaced with any existing group name.

  3. Then check if the user has been attached to the group with command:
    groups my-user-name

    It should return something similar:

    root@my-pc-name:/home/my-user-directory# groups my-user-name
    my-user-name : my-user-name cdrom sudo

    If sudo group name is printed it means we are in the group.

0 contributions

Checkout latest Findings & News:

Checkout latest questions:

Checkout latest wiki articles:

Hey 👋
Would you like to know what we do?
  • Dirask is IT community, where we share coding knowledge and help each other to solve coding problems.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.
Read more