Open In App

How to Create, Delete, and Modify Groups in Linux

Last Updated : 26 Mar, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

If you're using Linux—whether on a personal system, a company server, or a shared network—knowing how to manage groups is essential for handling multiple users efficiently. In simple terms, a group in Linux is a way to give shared access and permissions to multiple users without setting things up one by one.

In this article, we’ll cover everything you need to know about creating, deleting, and modifying Linux groups, along with the best practices for group-based access control. Whether you're a beginner or a system admin, understanding how to use Linux group management commands like groupadd, usermod, groupdel, and groupmod can boost your efficiency and improve your system’s security and structure.

What Is a Group in Linux?

In Linux, a group is used to manage the access permissions for more than one user at the same time. Instead of assigning file or directory access to all users separately, you can set up a group, add members to it, and assign privileges to the group. This is easier to access quicker, neater, and more securely when you're operating with multiple users or a team.

Why Use Groups in Linux?

Imagine a Linux group like a shared workspace. Any member of the group can read, edit, or view the same files—if the group has the access. This is ideal for:

  • Project teams in a company
  • Admins vs standard users
  • Shared computers at schools or labs

For example: You have a group of web developers. Rather than granting all developers read access to the project files individually, you create a group named devs and add all members to it. Then you establish permissions so devs can read and write in the project directory. All done in one step, everyone has the access they require.

Types of Linux Groups:

There are two types of groups in linux:

  • Primary Group: This is a user's default group when they are created. A user belongs to one primary group.
  • Secondary Group: These are groups a user can also join. Secondary groups provide additional access to resources without modifying the user's primary group.

For more details refer Group Management in Linux

How to Create a Group in Linux

Creating a groups on Linux enables us to set functionally similar users under one group for easier access management. This is useful for teams like developers, designers, or admins that need to collaborate on files in a centralized location.

Command to Create a New Group:

sudo groupadd groupname

For more details refer How to Create a new group in Linux | groupadd command

How to View All Groups in Linux

To check for existing groups on a Linux machine, you can execute a couple of commands which will show the groups available.

Command to List All Groups:

cut -d: -f1 /etc/group      # This command displays a simple list of all group names on your system
OR
getent group

How to Check Group Membership of a User

To check which groups a given user belongs to, the groups command can be used.

Syntax:

groups username

Also Read: How to Check the Groups a User Belongs to in Linux

How to Add a User to a Group

Adding a user to a group lets them access shared files, folders, and permissions tied to that group. This is useful when managing teams or giving specific rights.

Syntax:

sudo usermod -aG groupname username

The -aG option appends the user to the new group without removing them from their existing groups.

For more details refer How to Add User to a Group in Linux

How to Remove a User from a Group

When a user is removed from the group, that user loses the resources and privileges that are available through that group.

Syntax:

sudo gpasswd -d username groupname           # This command deletes the user from the specified group

For more details refer How to Remove Users from Groups in Linux

How to Change a User's Primary Group

In Linux, every user is allocated one primary group. His owning this primary group means that for all new files created by that user, the ownership group will be set to this primary group.

Syntax:

sudo usermod -g newgroup username

For more details refer How to Change The Primary Group of a User in Linux

How to Delete a Group in Linux

Removing a group from the system does delete the users from that group and all their details are retained irrespective of the specific group.

Syntax:

sudo groupdel groupname

For more details refer How to Delete a Group in Linux | groupdel command

How to Modify a Group in Linux

You can use groupmod to rename a group. This is convenient when names for groups need to be regularized or changed.

Syntax:

sudo groupmod -n newgroup oldgroup

Common Use Cases for Managing Groups

Groups in Linux are powerful when you want to organize users and control access without setting permissions individually

ScenarioWhy Use Groups
File sharing within a teamInstead of giving file access to each user manually, assign all members to a group so they automatically share access.
Admin vs regular user accessHelps create a secure environment by grouping users based on roles. Admins can have elevated permissions while regular users stay restricted.
Server managementGroups allow certain users to execute administrative tasks (like using sudo) without affecting others.
Educational institutionsSchools and colleges use groups to separate permissions for students, teachers, and IT staff. Each group can access only what's relevant to them.

Conclusion

Linux groups are a core part of system management and user access control. From creating a group for a development team to removing outdated permissions, group commands let you manage multiple users efficiently and securely. With just a few commands—like groupadd, usermod, groupdel, and groupmod—you can organize users, control access to files and tools, and keep your Linux system clean and secure.

Whether you're managing users in a school, office, or cloud server, groups make it easier to apply the right access to the right people—without confusion or clutter. In a world where data security and user management matter more than ever, mastering group management is a simple yet powerful skill every Linux user should have.


Next Article
Article Tags :

Similar Reads