Languages
[Edit]
EN

Bash - add user to exiting group in Linux

2 points
Created by:
Root-ssh
174740

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.

Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Bash

Bash - add user to exiting group in Linux
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join