How to Create, Delete, and Modify Groups in Linux
Last Updated :
26 Mar, 2025
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
Scenario | Why Use Groups |
---|
File sharing within a team | Instead of giving file access to each user manually, assign all members to a group so they automatically share access. |
Admin vs regular user access | Helps create a secure environment by grouping users based on roles. Admins can have elevated permissions while regular users stay restricted. |
Server management | Groups allow certain users to execute administrative tasks (like using sudo ) without affecting others. |
Educational institutions | Schools 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.
Similar Reads
Linux Commands Cheat Sheet
Linux, often associated with being a complex operating system primarily used by developers, may not necessarily fit that description entirely. While it can initially appear challenging for beginners, once you immerse yourself in the Linux world, you may find it difficult to return to your previous W
13 min read
grep command in Unix/Linux
The grep command in Unix/Linux is a powerful tool used for searching and manipulating text patterns within files. Its name is derived from the ed (editor) command g/re/p (globally search for a regular expression and print matching lines), which reflects its core functionality. grep is widely used by
7 min read
Sed Command in Linux/Unix With Examples
The SED command is one of the most powerful commands used during the process of text processing in Linux/Unix operating systems. The SED command is typically invoked for executing operations such as replace and search, text manipulation, and stream editing.With SED, you can manipulate text files wit
9 min read
25 Basic Linux Commands For Beginners [2025]
While performing a task, we all need shortcuts. Shortcuts help us to complete a task quickly. Linux comes with such commands which are one to two words, using that commands, you can perform several operations in no time. As a beginner, you must be aware of those basic Linux commands to complete an o
13 min read
Linux/Unix Tutorial
Linux is one of the most widely used open-source operating systems. It's fast, secure, stable, and powers everything from smartphones and servers to cloud platforms and IoT devices. Linux is especially popular among developers, system administrators, and DevOps professionals.Linux is:A Unix-like OS
10 min read
AWK command in Unix/Linux with examples
Awk is a scripting language used for manipulating data and generating reports. The awk command programming language requires no compiling and allows the user to use variables, numeric functions, string functions, and logical operators. Awk is a utility that enables a programmer to write tiny but eff
8 min read
How to Find a File in Linux | Find Command
Linux, renowned for its robust command-line interface, provides a suite of powerful tools for efficient file and directory management. Among these, the "find" command stands out as an indispensable asset, offering unparalleled versatility in searching for files based on diverse criteria. This articl
10 min read
ZIP command in Linux with examples
In Linux, the zip command compresses one or more files or directories into a single.zip archive file. This saves disk space, keeps data organized, and makes it simple to share or backup files. It's among the most used compression utilities, particularly when sharing large files via email or storing
6 min read
Introduction to Linux Shell and Shell Scripting
If we are using any major operating system, we are indirectly interacting with the shell. While running Ubuntu, Linux Mint, or any other Linux distribution, we are interacting with the shell by using the terminal. In this article we will discuss Linux shells and shell scripting so before understandi
8 min read
How to Securely Copy Files in Linux | scp Command
Secure file transfer is a crucial part of Linux systems administration. Whether moving sensitive files between local machines or transferring data between servers, SCP (Secure Copy Protocol) provides a fast, secure, and efficient way to copy files over a network. By utilizing SSH (Secure Shell), SCP
11 min read