24 C
Jaipur
Saturday, October 24, 2020

How to Add or Remove a User from a Group in Linux

Must read

US sanctions Russian institute linked to dangerous malware – Latest News

Washington imposed sanctions on a Russian research institute tied to the development of a dangerous computer program capable of causing catastrophic industrial damage, a...

Dell: Data is fuel, 5G fabric for digital transformation: Michael Dell – Latest News

Reiterating that technology has never been more central than it is in the pandemic times, Dell Technologies chairman and CEO Michael Dell has said...

8K TV: Samsung launches The 8K Festival with QLED 8K TVs

Samsung has launched 'The 8K Festival' under which its super premium QLED 8K TVs will be available at special prices with discounts. The...

Linux is by default a multi-user system (meaning many users can connect to it simultaneously and work), thus user management is one of the fundamental tasks of a system administrator. User management includes everything from creating, updating, and deleting user accounts or user groups on a Linux system.

In this short quick article, you will learn how to add or remove a user from a group in a Linux system.

Check a User Group in Linux

To check a user group, just run the following groups command and provide the username (tecmint in this example) as an argument.

# groups tecmint

tecmint : tecmint wheel

To check your own groups, just run the groups command without any argument.

# group

root
Check a User Group in Linux

Add a User to a Group in Linux

Before trying to add a user to a group, ensure that the user exists on the system. To add a user to a certain group, use the usermod command with the -a flag which tells the usermod to add a user to the supplementary group(s), and the -G option specifies the actual groups in the following format.

In this example, tecmint is the username and postgres is the group name:

# usermod -aG postgres tecmint
# groups tecmint
Add User to Group in Linux
Add User to Group in Linux

Remove a User from a Group in Linux

To remove a user from a group, use the gpasswd command with the -d option as follows.

# gpasswd -d tecmint postgres
# groups tecmint
Remove User from Group in Linux
Remove User from Group in Linux

Additionally, on Ubuntu and it’s derivative, you can remove a user from a specific group using the deluser command as follows (where tecmint is the username and postgres is the group name).

$ sudo deluser tecmint postgres

For more information, see the man pages for each of the different commands we have used in this article.

You will also find the following user management guides very useful:

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

US sanctions Russian institute linked to dangerous malware – Latest News

Washington imposed sanctions on a Russian research institute tied to the development of a dangerous computer program capable of causing catastrophic industrial damage, a...

Dell: Data is fuel, 5G fabric for digital transformation: Michael Dell – Latest News

Reiterating that technology has never been more central than it is in the pandemic times, Dell Technologies chairman and CEO Michael Dell has said...

8K TV: Samsung launches The 8K Festival with QLED 8K TVs

Samsung has launched 'The 8K Festival' under which its super premium QLED 8K TVs will be available at special prices with discounts. The...

iPhone 12 Users Can Now Download OS Updates Over 5G Data

Apple finally introduced 5G support with the launch of its latest iPhone 12 series. Now, as iPhones support high-speed 5G networks, the Cupertino tech...