Skip to main content
Keeping your Linux server secure and organized often involves managing groups and assigning users the appropriate permissions. In this guide, you’ll learn how to create, delete, and modify local groups, manage memberships, and adjust primary versus secondary group assignments.

Why Use Groups?

Groups let you grant permissions to multiple users at once. For example, imagine a shared directory for your development team:
  • Team members: John, Jack, Jane
  • Directory: /srv/dev-project
  • Required access: read/write
Instead of adjusting permissions per user, you can:
  1. Create a developers group
  2. Add John, Jack, and Jane to developers
  3. Change the directory’s group ownership to developers
  4. Grant the group read/write rights
The image shows a diagram of a "Developers" group with members named John, Jack, and Jane, alongside a folder icon labeled "Permission."
Now any member of developers automatically has the correct permissions. Remove a user from the group to revoke access, or add new members to grant permissions instantly. Beyond file access, group membership controls special privileges:
  • wheel or sudo group → run commands as root
  • docker group → manage Docker containers
Each user has one primary group (used when creating files or running processes) and zero or more secondary groups.

Creating a User and a Group

First, ensure you have a user (john) and create the developers group:

Managing Group Memberships

Use the gpasswd tool to add or remove users from secondary groups:

Changing a User’s Primary Group

To switch John’s primary group to developers, use usermod with the --gid option:
gpasswd syntax is gpasswd [--add|--delete] username group
usermod syntax is usermod --gid group username

Renaming and Deleting Groups

Rename a group from developers to programmers:
Delete a group when it’s no longer needed:
If the group is the primary group for any user, groupdel will fail with:
Change the user’s primary group first:
Then run:

Quick Reference Table

Practice these commands on a test environment to master Linux group administration!

Watch Video

Practice Lab