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

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
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

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

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 liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

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.

We are thankful for your never ending support.

Got something to say? Join the discussion. Cancel reply

Scroll back to top