Sharing uid/gid between multiple Linux users

Published: (January 5, 2026 at 02:03 AM EST)
1 min read
Source: Dev.to

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.

Back to Blog

Related posts

Read more »

The RGB LED Sidequest 💡

markdown !Jennifer Davishttps://media2.dev.to/dynamic/image/width=50,height=50,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%...

Mendex: Why I Build

Introduction Hello everyone. Today I want to share who I am, what I'm building, and why. Early Career and Burnout I started my career as a developer 17 years a...