Tag Archives: how to check gid in linux

Understanding /etc/group file

/etc/group is the key file in any Linux Unix system for user management. Learn fields, formats within /etc/group file. Understand the meaning of each field and how it can be set.

In this post, we are going to see the format, the content of /etc/group file. /etc/group (will be called as group file henceforth in this post) is the popular file after /etc/passwd, when it comes to user in any Linux or Unix based system. Every administrator should be familiar with this file. Rather whenever one starts working on Linux Unix based system this file should be covered during his/her basis learning itself.

The group file is a human-readable file that contains information about user groups on the system. Typical /etc/group file looks like below :

# cat /etc/group
root:x:0:root
bin:x:1:root,bin,daemon
daemon:x:2:root,bin,daemon
sys:x:3:root,bin,adm
adm:x:4:root,adm,daemon
tty:x:5:

Since its normal text file, commands like cat, more will work without any issue on it.

If you observe the above file, it has values separated by colons :. Each row is one entry. One entry is for one group. For every group (row) there are 4 fields defined separated by a colon. Those four fields are :

  1. Group name
  2. encrypted password for the group
  3. group id
  4. group members

Let’s see one by one :

Group name

Its a group name by which group is being identified for admins/humans. This name is used in all group management/user management related commands. New group name entry gets added in this file when groupadd command is used.

Encrypted password for the group

Its password in an encrypted format. In the above example, you see x instead of encrypted password since /etc/shadow file is generated on the system. The encrypted password is found in /etc/gshadow file in such a case.

Group ID

Its numeric id assigned to the group. Normally kernel identifies group by this field. This ID also features in /etc/passwd file in the 4th field. More information on GID can be found here. Group id gets generated automatically when a group is created using groupadd command.

Group Members

This is a list of user names separated by commas which are member of this group. File or directory permissions assigned to the group will be inherited to all these group members.