Skip to content
Follow
Ubuntu Linux

How to Add Users to Groups in Ubuntu Linux

Richard
Written by
Richard
Jan 2, 2023 Updated Aug 13, 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 what files people can open and what tasks they can do on your computer. Groups act like shared checklists that grant access to system folders and programs for multiple accounts at once.

For example, putting an account into the sudo group gives you the power to run administrator commands, which works just like being an administrator on Windows. To do this, you type a simple command in the terminal, such as sudo usermod -aG sudo alex to add a person named alex to that group.

⚡ 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

Existing users join additional groups in Ubuntu Linux to gain extra permissions, such as running specific commands. The command sudo usermod -a -G groupname username handles this action. Replacing ‘groupname’ with the desired group and ‘username’ with the login name targets the correct account.

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 covered so far assume the groups already exist.

Terminal commands accomplish this group membership update in Ubuntu Linux. For example, executing sudo usermod -aG sudo geekrewind adds the user geekrewind to the sudo group. This grants geekrewind the permissions of the sudo group, allowing them to run commands with administrator privileges.

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

Always include the -a flag so the system appends the user to the new group instead of overwriting their existing memberships. Watch out for typos here, because targeting a missing group causes the tool to throw 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. The command 'sudo usermod -g groupname username' shifts this main group, where 'groupname' is the desired group name and 'username' is the user's login name.

Primary group modifications in Ubuntu Linux rely on the usermod command paired with the -g option.

🐧Bash / Shell
sudo usermod -g groupname username

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

🐧Bash / Shell
sudo usermod -g developers geekrewind

Account creation allows defining primary and secondary groups simultaneously. Setting up a new geekrewind account with a primary group of users and secondary groups of wheel and developers uses this structure:

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

Instructions for listing all groups in Ubuntu Linux live in the related post below.

How to list groups in Ubuntu Linux

Proper group management keeps multi-user systems secure and organized.

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; users cannot join 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 *