fbpx
Black Friday limited time 25% of on our life-time plans using code: LMT25
  • 00Days
  • 00Hours
  • 00Minutes
  • 00Seconds
Search
Close this search box.

Linux User and Group Management: How to Add, Create, List, and Manage Users and Groups

linux groups

Table of Contents

Get up to 50% off now

Become a partner with CyberPanel and gain access to an incredible offer of up to 50% off on CyberPanel add-ons. Plus, as a partner, you’ll also benefit from comprehensive marketing support and a whole lot more. Join us on this journey today!

We are going to learn the “Linux add user to group” concept. User and group management is an essential aspect of Linux administration. It allows you to have control over user permissions, and resource allocation, and to define what each user can access on the system. Once you understand how to work with users and groups efficiently, it enhances security and enables smooth system management. In this article, we shall discuss adding users to groups, creating users, listing groups, and managing Linux Foundation subgroups. Moreover, we’ll tell you how CyberPanel simplifies administration. By the end of this article, you’ll have a complete understanding of Linux user and group management.

Understanding Linux Groups

In Linux, groups are used to organize and manage users. They grant them different permission and access rights based on their group membership. By default, every group belongs to the primary group. But, they can also be added to secondary groups to grant additional permissions.

For example, adding a user to the “docker” group allows them to run Docker commands without needing sudo permissions.

Listing Groups In Linux

You can use the following command to list groups in Linux a user belongs:

command to list groups in Linux to a user belong

To “list groups Linux” for a particular user, you can use th

group listing

Adding A User To A Group In Linux

You can get “Linux add user to group” by using the usermod command.

Tech Delivered to Your Inbox!

Get exclusive access to all things tech-savvy, and be the first to receive 

the latest updates directly in your inbox.

Example: Add a User to a Group

You can use the following command to add an existing user to a specific group without removing them from their current groups:

adding user to specific group

-aG flag, adds users to the group without removing existing group memberships on the users.

Why is this important? If you omit -aG, you will instead remove the user from any other groups they may exist in which can lead to issues when it comes to permissions.

To add a user called “john” to the group “sudo”:

adding user

Creating A New User And Assigning To A Group

You can use the useradd command to create a user and assign them to a group simultaneously. For example, to create a new user and add user to sudo group in Linux:

adding users to sudo group

This example assigns the user to a primary group. For assigning the user to additional groups during creation, you can use the following command:

assigning users additional group

This above command will add user and group in Linux. It allows you to be a part of multiple groups like sudo and developers. 

You can create a new user and add them directly to the sudo group:

creating and adding user to sudo group

Linux Show Groups

To check which groups a specific user belongs to, use the following command:

Enhance Your CyerPanel Experience Today!
Discover a world of enhanced features and show your support for our ongoing development with CyberPanel add-ons. Elevate your experience today!

checking users groups

For example, to view the groups for the user john:

view group

Viewing Users In A Group

Oftentimes, one wants to know which users are members of a specific group. One can use the getent command to view group membership. With that, you can view users assigned to groups in Linux:

viewing users
output

To view users in the sudo group:

The above command lists all users with administrative privileges on the system. 

Removing A User From A Group

To remove a user from a group, you can use the gpasswd command. This may come in handy if, for instance, one needs to remove access to some system features or restrict administrative access.

To “Linux put user in group” or remove them from it, you can use:

removing user from group

For example, to remove “John” from the sudo group:

removing user

Linux Foundation Sub-Groups

Linux allows you to create multiple sub-groups to manage different permission levels. For instance, you can create groups under the Linux foundation subgroups like developers or admin. 

To “Linux add user to group” in Linux for these sub-groups, you can execute:

adding user for subgroups

Linux Useradd to Group

You can directly assign new Linux users to groups during the user creation process. This is done using the Linux useradd to group command. It is pretty useful when one creates new users for particular roles.

Command:

useradd command

For example, if you want to create a new user named “jane” and assign her to the developers group, the command would look like this:

assigning user developer group

In the above case, “jane” is created with a home directory. And she is also added to a specific group. 

Adding Users to Multiple Groups in Linux

You can use the usermod command with the -G option to achieve this:

adding users to multiple groups

For example, if you want to “Linux put user in group” “developers” and “testers”, you can run:

putting user in group

Example of Complete Workflow

Here is a complete workflow of creating a user, adding them to a group, and listing group memberships:

1. Create a new user named alice:

creating new user

2. Put User in Group:

putting user in group

3. Check groups:

checking group

4. List all groups on the system:

listing groups

Role of CyberPanel in Web Hosting Management

The CyberPanel is one of the most intuitive web hosting control panels, developed based on the OpenLiteSpeed web server. CyberPanel has been designed to make the management of a website and server as smooth as possible. Here are the benefits:

  • CyberPanel boasts a modern interface that is user-friendly for everyone regardless of their level of skill.
  • You can easily create, manage, and delete websites with support for all web technologies, such as PHP and WordPress.
  • OpenLiteSpeed assures that one-click installation, administration, and deletion of websites come with features like caching, SSL management, and CDN integration for superb performance.
  • Its built-in features to assure immunity to vulnerability include automated installation of SSL, firewall, and mod_security.
  • It will automatically manage email accounts, set up forwarders, and configure spam filters without any effort on the control panel.
  • You can create regular backups and restore the website’s database or other Databases for safety and easy recovery.
  • You can enable easy creation and management of MySQL and MariaDB, with built-in SQL query execution.
  • Deploy applications in a containerized environment that makes it easier to manage your applications
  • We offer API support for integration with other systems and automation of the process.
  • You can also ADMINISTER multiple servers centrally, thereby smoothing out the management process.

Linux Add User to Group: FAQs

1. How can I add a user to a group in Linux?

You can get “Linux add user to group” using user management commands. It updates group membership so that users acquire the appropriate permissions attached to the specified group.

2. How do I list all the groups a user in Linux has access to?

You can list groups in Linux just to see all the groups for a specific user so you know how much access he has at any time within the system.

3. What are the Linux Foundation sub-groups?

Linux Foundation sub-groups are subset groups that allow for more access control to users. They can be formed for handling different roles to ensure that users have access to the specific task they need for their specific role at the organization instance, developers or support.

4. What is the most efficient way to check all groups in Linux?

You can list groups on your Linux system using commands. You can also describe all groups to get a good feel of the general organizational structure and user group configurations.

5. How can one delete a user from a group in Linux?

In case you need a person to be added or removed from a group, you can edit memberships for groups based on your requirements, thus providing the user with the right to access specific resources based on his role.

Final Words On Linux Add User To Group: Empower Your Linux Management Skills

So, we have done with “Linux Add User To Group”. Effective user and group management is the core of Linux administration because it assures the securing a system and the distribution of system resources. With mastering commands added to add people to their groups, and to create new accounts and group memberships, you may optimize access to your system and make it work better for you. You will be better set up to deal with user permissions when using commands like usermod, useradd, and gpasswd.

Stop here and take CyberPanel to streamline your stuff further. Let’s start with these habits today and unlock the full potential of your Linux environment. Read on or get more in-depth tips on how to get a lot done faster. Do join our community or follow our resources to get further assistance and learning!

Hasib Iftikhar
I'm Hasib Iftikhar, a dedicated technical writer at CyberPanel, joining the team in July 2024. With three years of extensive experience in content writing, I specialize in copywriting, article writing, guest posting, affiliate content writing, and SEO. My expertise ensures that each piece of content I create is engaging, informative, and optimized for search engines, helping businesses enhance their online presence and reach their target audience effectively.
Unlock Benefits

Become a Community Member

SIMPLIFY SETUP, MAXIMIZE EFFICIENCY!
Setting up CyberPanel is a breeze. We’ll handle the installation so you can concentrate on your website. Start now for a secure, stable, and blazing-fast performance!