Skip to content
Follow
Ubuntu Linux

How to Add Users to Groups in Ubuntu Linux

Richard
Written by
Richard
Jan 2, 2023 Updated Jul 14, 2026 3 min read
How to Install VMware Workstation Player on Ubuntu Linux
How to Install VMware Workstation Player on Ubuntu Linux

Adding users to groups in Ubuntu Linux controls their permissions and access to files. Groups act like lists of people who share the same rights, making it easier to manage who can do what on your computer.

For example, adding a user to the ‘sudo’ group gives them the power to run administrative commands, much like having administrator rights on Windows. This is a common way to grant temporary or specific elevated privileges.

To add an existing user to a new group, you use a specific command in the terminal. For instance, to add a user named ‘alex’ to the ‘sudo’ group, you would type the command: `sudo usermod -aG sudo alex`.

⚡ Quick Answer

Use the `usermod -aG groupname username` command in the terminal. This appends the specified user to the existing group without removing them from other groups. For example, `sudo usermod -aG developers jane` adds the user ‘jane’ to the ‘developers’ group.

Add a user to a group in Ubuntu Linux

You can add an existing user to a group in Ubuntu Linux to grant them extra permissions, such as allowing them to run specific commands. To add a user to a group, use a command like `sudo usermod -a -G groupname username`. Replace ‘groupname’ with the desired group and ‘username’ with the user’s login name.

Here’s the format for adding a user to a group in Ubuntu Linux.

🐧Bash / Shell
sudo usermod -a -G groupname username

Add a user to multiple groups.

🐧Bash / Shell
sudo usermod -a -G group1,group2 username

The commands we’ve covered so far assume the groups already exist.

To add users to groups in Ubuntu Linux, run a command in the terminal. For example, to add the user `geekrewind` to the `sudo` group, you would execute the command `sudo usermod -aG sudo geekrewind`. This command grants `geekrewind` the permissions of the `sudo` group, allowing them to run commands with administrator privileges.

🐧Bash / Shell
sudo usermod -a -G sudo geekrewind

When adding a user to a group, use the -a option (which means append) to add them to that group without removing them from others. If the group doesn’t exist, the command will return an error.

Change a user’s primary group in Ubuntu Linux

Changing a user’s primary group in Ubuntu Linux controls file and folder access for that user. New files created by a user typically belong to their primary group. You can change this main group using the command ‘sudo usermod -g groupname username’, where ‘groupname’ is the desired group name and ‘username’ is the user’s login name.

In Ubuntu Linux, you can change a user’s primary group. To do this, you’ll use the usermod command with the -g option.

🐧Bash / Shell
sudo usermod -g groupname username

For example, use the commands below to change the primary group of the user geekrewind to developers.

🐧Bash / Shell
sudo usermod -g developers geekrewind

You can also define a user’s primary and secondary groups when you create their account. For example, here’s how you’d create a new geekrewind account, setting its primary group to users and its secondary groups to wheel and developers:

🐧Bash / Shell
sudo useradd -g users -G wheel,developers geekrewind

For instructions on listing all groups in Ubuntu Linux, refer to the related post below.

How to list groups in Ubuntu Linux

That should do it!

Conclusion:

  • Adding users to groups in Ubuntu Linux is essential for organizing and administering user accounts.
  • Administrators can effectively manage resource access and permissions by understanding the distinction between primary and secondary groups.
  • The steps outlined provide clear guidance on adding users to single and multiple groups and changing a user’s primary group.
  • Readers can refer to the provided link for instructions on listing all groups in Ubuntu Linux, enhancing their understanding of user and group management.

How do I add a user to multiple groups in Ubuntu?

To add a user to multiple groups, run the usermod command. All groups listed must already exist on the system; you can’t add a user to non-existent groups. The -a option tells usermod to append or add this user to other groups.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

📚 Related Tutorials

How to List User Profiles and Accounts in Windows 11
Windows How to List User Profiles and Accounts in Windows 11
Working with Sudo and Su Commands in Ubuntu Linux
Ubuntu Linux Working with Sudo and Su Commands in Ubuntu Linux

No comments yet — be the first to share your thoughts!

Leave a Comment

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