The role of the /etc/group file is to act as the central database for user groups on a Linux system.
Its main purposes are:
- Defining Groups: It lists every group that exists on the system.
- Organizing Users: It matches users to their secondary groups. This makes it easy for administrators to manage many users at once by assigning permissions to a group rather than to each individual user.
- Permission Management: When you try to access a file or run a command, the system checks
/etc/groupto see if you are a member of a group that has the required permissions.
Example from your environment:
When you ran cat /etc/group | grep -E "labex", you saw:
sudo:x:27:labex
This entry tells the system that:
- A group named sudo exists.
- Its ID is 27.
- The user labex belongs to this group.
Because labex is in the sudo group, the system grants you administrative privileges when you use the sudo command.
In short, /etc/group is the "rulebook" the system uses to decide which group-based permissions you are allowed to have. You're now ready to see how these groups are used to control file access in the next steps!