Sharing uid/gid between multiple Linux users
Source: Dev.to
Sharing uid/gid between multiple Linux users
It’s possible to create multiple users and groups that share the same UID/GID. While this can be confusing, there are scenarios where it’s useful.
Groups
To have two groups share the same GID, edit the following files:
/etc/group/etc/group-/etc/gshadow
Add a new line that mirrors the original group line, changing only the group name. For example, given the original line:
group:bill.gates:x:1000:bill.gates
Create a new line:
group:bill.fences:x:1000:bill.gates
After saving the files, both bill.gates and bill.fences will have gid=1000 and will include the same user bill.gates.
Users
The same approach applies to users. Modify these files:
/etc/passwd/etc/passwd-/etc/shadow
Add a new entry that duplicates the original user line, changing only the username. Be mindful of the order of entries: the first matching line for a given UID is typically the one that applications will display.
Note: Some applications that work with UIDs may only show the first username that matches the UID.