Skip to main content
In this lesson you’ll learn how to create, modify, and delete groups, assign users to them, and verify the resulting entries in /etc/group. Managing groups simplifies permission control and is essential for multi-user Linux systems and team-based workflows.
A dark presentation slide titled "Demo: Managing Groups" on the left with a blue line-icon of three connected people on the right. The design is minimalist with a navy background.

Quick overview — what you’ll do

  1. Create system groups.
  2. Create user accounts.
  3. Assign users to supplementary groups and change primary groups.
  4. Rename groups and change GIDs.
  5. Remove groups and validate /etc/group.

1) Create groups

Create the groups you need with groupadd:
Verify the new groups by inspecting /etc/group or using grep:

2) Create users

Create three example users and their home directories with -m:
Note: By default each user gets a private primary group that matches the username (for example, groupuser1).

3) Assign supplementary groups

Use usermod -G to set supplementary groups for an account. Important: the uppercase -G replaces the entire supplementary-group list; to append instead of replacing, use -aG.
Use -G to set supplementary groups (this replaces the list). Use -aG to append to the existing supplementary groups without removing any existing ones.
Example — set developers and admins as supplementary groups for groupuser1, then append the wheel group:

4) Change the primary group

To change a user’s primary group, use the lowercase -g:

5) Rename a group and change its GID

Use groupmod -n to rename a group and groupmod -g to change its GID. Example — rename developers to devs and set the devs GID to 20000:
Verify the changes by inspecting /etc/group (excerpt):

6) Remove groups

When you need to delete groups, use groupdel. Be careful not to remove groups that are required by system services or in active use.
Warning: Deleting a group that is in use can cause permission and access issues. Verify memberships and service dependencies before running groupdel.
Example — delete admins and devs:

Commands summary

Validation & tips

  • Always verify group membership with id <username> and check /etc/group.
  • Use -aG when you only want to add a supplementary group without removing existing ones.
  • Be cautious changing GIDs if files or directories are already owned by the old GID; you may need to update ownership with chown.
This concludes the demo. Using groupadd, groupmod, groupdel, and usermod you can effectively manage primary and supplementary group memberships and control GIDs that appear in /etc/group.

Watch Video