Languages
[Edit]
EN

Bash - add user to exiting group in Linux

2 points
Created by:
Root-ssh
6750

In this short article we want to show how in Linux, add user to exiting group using Bash (or any Command Line).

Quick solution:

sudo usermod -a -G group_name user_name

What will cause the user_name user will have attached additional group_name group.

Note:

  • in Linux each user is assignet to main group and additional groups,
  • run usermod command as super user.

Where:

  • -a means add operation,
  • -G means additional group.

Practical example

Type following command:

usermod -a -G sudo john

Testing:

root@debian# groups john
john : john sudo

Note: we can see now john is assigned to sudo group too.

Hey 👋
Would you like to know what we do?
  • Dirask is a friendly IT community for learners, professionals and hobbyists to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.