Data Centers

How to add users to groups in Linux

Jack Wallen shows you how easy it is to add users to groups from the Linux command line interface.

Since inception, Linux has been a multi-user platform. You can create as many users as you need on your Linux servers and desktops. But the ability to simply add users isn't the only aspect that makes Linux so powerful and flexible. In addition to users, you can create groups and then add users to those groups. Groups can be administrative in nature, created for departments or tasks, and so much more. But how do you add users to those groups? I'm going to show you just that. In fact, I'm going to show you how to manage this from the command line. I know, right? The command line! Ack! Actually it's quite simple. Let's say you're working with a distribution that uses sudo and instead of adding users to the sudoers file, you'd rather go the safer route by adding users to the sudo group. How do you do that? Easy.

Let's add user olivia to the group sudo. To do this, open up a terminal window and issue the command sudo usermod -aG sudo olivia. You'll be prompted for your sudo password. Upon successful authentication, the user will be added. You can check to make sure olivia was added to the sudo group with the command grep sudo /etc/group. Hit Enter and you will see all of the members within the group listed.

That's all there is to adding a user to a group in Linux. That wasn't even remotely hard. And here you were worried it would challenge your Linux mettle. Group on, my friends, Group on.

Also See

linuxhero.jpg
Image: Jack Wallen

About Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.

Editor's Picks

Free Newsletters, In your Inbox