How To: Add A User To A Group

Today’s article is going to teach you how to add a user to a group. It’s not particularly difficult, but it’s something everyone should know. If you don’t know how to add a user to a group, this article is meant for you.

This article is going to make a few assumptions. The first is that you’re familiar with cat /etc/passwd which will tell you what groups a user belongs to. It also assumes that you’re familiar with cat /etc/group – where you can find supplementary information.

Furthermore, you should also be aware of the groups command, which is a handy command, probably worthy of its own article, that lets you know what groups you already belong to. So, there’s a bit you’re expected to know already, or at least be familiar with conceptually, but trust me when I say this is a very simple article and very straightforward.

Anyhow, if you’ve looked at those previous commands, you’ll see there are a lot of groups. Your user may or may not be a member of those groups, as the groups command will let you know. For myriad reasons, you may wish to add yourself or another user to different groups. Well, that’s what this article is actually about. It’s about showing you how to …

Add A User To A Group:

This article requires an open terminal, like many other articles on this site. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

The command we’ll be using for this exercise is ‘usermod‘. You can get a head start by using ‘man usermod‘ but we really won’t be needing most of that information. In reality, we only care about a couple of the flags. Still, usermod is a pretty expansive command, with many options. Still, it defines itself simply as:

usermod – modify a user account

See? Pretty straightforward still. The command we actually want is:

The -a means append (add) the user. The -G means groups – so the -a -G means add a user to a group. You can verify the command worked (though, well, you really don’t need to – ’cause, assuming  you did it properly it’ll work) with the following:

See? That’s it. You’ve learned how to add a user to a group – in under 500 words!

Closure:

Yup, it’s a nice and easy article for a skill you may need as you work with advanced group permissions. If you want to refine the permissions in your system, the sky’s the limit and it’s easy enough to add a user to a group if you need to. So, there’s another tool in your toolbox.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Subscribe to Newsletter!
Get notified when new articles are published!
We promise to never share your email!
icon

Author: KGIII

Retired mathematician, residing in the mountains of Maine. I may be old and wise, but I am not infallible. Please point out any errors. And, as always, thanks again for reading.

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter
Get notified when new articles are published! It's free and I won't send you any spam.
Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.