Table of Contents
- What is a Group in Linux?
- Types of Groups
- Where Group Data is Stored
- Essential Group Management Commands
- Conclusion
Description
Learn how to manage groups in Linux using commands like groupadd, gpasswd, groupmod, and more. Includes clear examples and file references.
Groups in Linux help system administrators organize users, manage permissions, and control access more efficiently especially in multi-user environments like servers and enterprise systems.
In this guide, you’ll learn how to create, manage, and delete group accounts using real command-line examples.
What is a Group in Linux?
A group is a collection of user accounts. Groups are used to assign common permissions to multiple users and simplify system administration tasks.
For example, giving read/write access to a project folder for all members of the dev
group is easier than setting permissions for each user individually.
Types of Groups
Group Type | Description |
---|---|
Primary Group | Automatically created when a new user is added. Each user belongs to exactly one primary group. Deleting the user also removes their primary group. |
Secondary Group | Created and managed by superusers. Users can belong to multiple secondary groups for shared access to files or services. |
Where Group Data is Stored
File | Purpose |
---|---|
/etc/group |
Stores group account properties |
/etc/gshadow |
Stores group admin and secure group info |
Essential Group Management Commands
Create a Group
groupadd testers
- Creates a new group named testers
Check Group Properties
grep testers /etc/group
- Displays group info like GID and members
Modify Group ID
groupmod -g 2025 testers
- Changes the GID of the developers group to 2025
Add or Remove Group Members
gpasswd -a alice testers
- Add a user to a group
Verify if alice is added to the testers group
cat /etc/group | grep testers
Remove a user from a group
gpasswd -d alice testers
Options you can use on gpasswd
Add/Remove Multiple Users to a Group
Current users
gpasswd -M seth,mike,rose,mary,helen testers
Note: Adds multiple users to the group. This replaces any existing members include all users (new + existing) to avoid removing others accidentally
Assign a Group Admin
gpasswd -A seth testers
- Makes seth
a group administrator for tester
Check Group Admins
grep testers /etc/gshadow
- Shows who the group admins are
Delete a Group
groupdel testers
- Deletes the testers group from the system.
When you run the command grep testers /etc/group, it returns no results because the testers group has already been deleted from the system.
Tip:
Use the man
command to explore additional options and details for any command. For example, man useradd
shows all available flags and usage examples.
Conclusion
Groups are essential for managing user permissions in an organized and efficient way especially in teams or multi-user systems.