Pcornel
Linux · Users & Groups

UID / GID

Cheat sheet · https://pcornel.dk/topic.php?topic=2699

Back to the Topic

Answer

The UID (user ID) and GID (group ID) are the numbers the kernel actually uses; names are just lookups. UID 0 is root; system accounts typically use 1–999 and regular users 1000 and up.

Remember

Permissions follow numbers: the same name with a different UID on another host (NFS, rsync) gives the wrong owner. Keep UIDs consistent across systems or use a directory service. Files owned by a deleted user show a bare number.

First checks

  • ls -ln <path> — numeric owner and group
  • id <user> — UID, primary group and groups
  • getent passwd <user> — account entry (local or directory)
  • getent group <group> — group members
  • sudo -l -U <user> — what the user may run with sudo

Commands

id <user>
Read current Users, Permissions & sudo state for a bounded verification step.
sudo

Verify in this order

process runs with UID/GID → file has owner UID/GID → kernel compares numbers → names resolved only for display

Where it usually breaks

First mismatch in identity/group resolution → Unix mode/ACL/capability → mount/sandbox constraint → SELinux/AppArmor policy → credential/TLS trust → protected operation; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2699

Confirmation

Confirm action

Continue?