Linux is a multi-user operating system, which means multiple users can work on the same system simultaneously. To manage users efficiently, Linux provides a concept called groups. A group is a collection of users that share common permissions and access rights to files and directories. This makes it easier to manage user access rather than setting permissions individually for each user.
For example, if you manage a team of developers, you can create a group called developers and add all team members. This way, you can grant or restrict access to files and directories for the entire group instead of managing individual users separately.
In this detailed article, we will walk you through creating a new group in Linux using simple commands. Understanding group management is essential for maintaining security and efficiency, whether you manage a personal system or an enterprise-level server.
Prerequisites
Before proceeding, ensure that you:
➔ Have access to a Linux system.
➔ Are logged in as a root user or a user with sudo privileges.
Also Read: Create Zip File With Command in Linux With Examples
Steps to Create a Group in Linux With Examples
➢ Step 1: Check Existing Groups
Before you start creating a new group, checking the existing groups on your system is good practice. To do this, you have to run the following command:
cat /etc/group |
This will display a list of all existing groups on the system.
Alternatively, you can use:
groupmod –list |
Now that you know the existing groups, let’s create a new one!
➢ Step 2: Create a New Group
To create a new group in Linux, you have to use the groupadd command followed by the group name.
Syntax:
groupadd group_name |
Example:
Let’s say you want to create a group called developers. You can do this by following this:
groupadd developers |
The group will be created if the command runs successfully without any error messages.
➢ Step 3: Verify the Newly Created Group
To confirm that the group was created, you can check the /etc/group file again by running:
grep developers /etc/group |
This should output a line similar to:
developers:x:1001: |
The 1001 is the Group ID (GID) assigned to the group.
➢ Step 4: Add a User to the Group
Once your group is created, you can add users to it. To do so, you must use the usermod command.
Syntax:
usermod -aG group_name username |
Example:
To add a user named john to the developers group:
usermod -aG developers john |
To verify if the user was successfully added to the group, run the following:
groups john |
This will display all groups that john is a member of.
Also Read: How to Create a User in Linux & Add it to the sudoer File?
Modifying Groups in Linux
1. Delete a Group (If Needed)
If you no longer need a particular group, you can delete it using the groupdel command.
Syntax:
groupdel group_name |
Example:
If you want to delete the developers group:
groupdel developers |
It is important to ensure that no user is dependent on the group before deleting it.
2. Rename a Group
If you are looking to rename a group, use the groupmod command.
Syntax:
groupmod -n new_group_name old_group_name |
Example:
If you want to rename developers to dev_team:
groupmod -n dev_team developers |
3. Setting a Group Password
You can set a password for a group using the gpasswd command. This allows users to join the group temporarily with the password.
Syntax:
gpasswd group_name |
Example:
If you want to set a password for the developers group:
gpasswd developers |
After running this command, you will be prompted to enter and confirm the new password.
4. Remove Users from a Group
If you want to remove a user from a group, use the gpasswd command.
Syntax:
gpasswd -d username group_name |
Example:
If you want to remove john from the developers group:
gpasswd -d john developers |
Also Read: How To Remove Directory in Linux With Command?
Conclusion
Groups in Linux make user management much easier by allowing administrators to assign permissions collectively. Instead of setting access control for each user individually, you can assign them to groups and manage permissions at the group level.
This guide covered the basics of creating and managing groups in Linux. You learned how to:
- Check existing groups
- Create a new group using groupadd
- Verify group creation
- Add users to a group
- Delete a group if needed
Understanding how to create and manage groups is essential for Linux administrators and even regular users who want to manage their systems efficiently.
Keep exploring, and happy learning!

Upgrade to Host IT Smart and Supercharge your site today!