The /etc/group File Explained
On a Linux system, every user must be a member of at least one group. When we create a user account, the shell automatically creates a group for the user. This group is called the primary group of the user. Unless we manually change or update the primary group name of a user, it matches the user name. For example, if the username is john, his default primary group name will also be john. Besides the primary groups, you can also add additional groups.
All additional groups are secondary groups. A user can join as many secondary groups as he wants. There are no restrictions for secondary groups. However, a user can join only one primary group.

The file /etc/group stores group information. Each line in this file stores one group entry. Each line contains the following four fields separated by colons.
Group name : group password : GID : group members
Group name
This field stores the group name. There are three essential rules for a group name.
- Each group name must be unique.
- A group name must be less than 255 characters in length.
- A group name must start with a letter.
Group password
If we configure a group password, this field stores a placeholder character indicating that the password is available in a separate file. If we do not configure a group password, this field remains blank.
GID
This field saves the group ID. Linux uses the group ID to track, log, authenticate, and monitor group activities. It assigns a unique group ID to each group.
Group members
This field stores the username of group members. A group can have many members.

The /etc/group file entry example
Linux automatically creates the primary group for the users when we add them. We manually create the secondary groups. The following command adds a new group.
#groupadd [group-name]
The above command adds a new entry at the end of this file. It creates an empty group. It does not add any group members. We must manually add group members. The following command adds a user to the group.
#usermod -G [secondary group name] [username]
Example
- Add a new user.
- List or view the last entry of the /etc/group file.
- List or view the last entry of the /etc/passwd file.
- Verify the primary group.
- Add a new group.
- Add the user to the group.
- List or view the last entry of the /etc/group file.
- Verify the secondary group.
#useradd testuser #tail -1 /etc/passwd #tail -1 /etc/group #groupadd testgroup #usermod -G testgroup testuser #tail -1 /etc/passwd #tail -1 /etc/group

This tutorial is part of the tutorial series 'Linux User and Group Management Explained with Examples'. Other parts of this series are the following.
Chapter 01 Difference between the root user and super (sudo) user
Chapter 02 Linux User Management Explained with Examples
Chapter 03 Linux Group Management Explained with Examples
Chapter 04 Password aging policy Explained with chage command
Chapter 05 The /etc/group File Explained
Chapter 06 The /etc/gshadow File Explained
Chapter 07 The /etc/passwd file in Linux Explained with Examples
Chapter 08 The /etc/shadow file in Linux Explained with Examples
Chapter 09 The useradd command Explained
Chapter 10 The gpasswd command Explained
Chapter 11 The chage command Examples and Usages
Conclusion
The /etc/group file saves group information. Each line in this file represents a group entry. Linux automatically creates group entries for primary groups. Secondary groups are optional. We manually add them as per requirements.
By ComputerNetworkingNotes Updated on 2026-04-10