The /etc/passwd file assigns a user to its primary group by specifying the group ID (GID) of the
primary group in the fourth field of each line. The /etc/passwd file contains the basic information for
each user account on a Linux system, such as the user name, user ID (UID), group ID (GID), home
directory, login shell, etc. The format of each line is:
username:password:UID:GID:comment:home:shell
For example, the following line assigns the user bob to the primary group bob, which has the GID of
1001:
bob:x:1001:1001::/home/bob:/bin/sh
The /etc/passwd file can be viewed and modified by the root user or by using the useradd, usermod,
or userdel commands123. The other files listed in the options do not assign a user to its primary
group. The /etc/pgroup file does not exist by default on most Linux systems, and it is not related to
the primary group. The /etc/shadow file contains the encrypted passwords and other information for
each user account, but not the primary group4. The /etc/group file contains the information for each
group on the system, such as the group name, group password, group ID, and group members, but
not the primary group of each user5. The /etc/gshadow file contains the encrypted passwords for
group accounts. Reference: 12345