Linux: Primary vs Secondary Groups

Posted . Visible to the public.

In /etc/passwd you'll see a primary group assigned to each user like this:

Code:
john:x:1001:1001:John:/home/john:/bin/bash

User "john" here has uid 1001 and his primary group is also 1001. When john creates files, they will be owned by john and assigned to group 1001.

john can also belong to other ("secondary") groups. These assignments are made in /etc/group:

Code:
someusers:x:500:john,jill,jack,harry

Here john, jill, jack, and harry also belong to the group called "someusers" with gid 500. So john will also have the privileges of this group, but files he creates won't be assigned to this group. They will be assigned to group 1001 instead since that's his primary group.

Luis Romero
Posted by Luis Romero to Custom Exposure (2014-05-22 23:24)