A user identifier (UID) is the unsigned integer that the Linux kernel uses to represent a user account, and it is the value against which every ownership and permission check is made. In Linux permissions, usernames exist only for humans: files, processes and access decisions are tied to the numeric UID, not to the name.
Every process carries a set of UIDs, and every file stores the UID of its owner in its inode. When a process opens a file, the kernel compares these numbers and applies the owner, group or other permission bits accordingly. Understanding the UID is therefore essential for administering accounts, troubleshooting access denied errors and securing services.
How Linux maps names to user identifiers
Linux maps usernames to UIDs through the Name Service Switch (NSS), which by default reads the local file /etc/passwd. The third colon-separated field of each line holds the UID, and the fourth holds the primary group identifier. Directory services such as LDAP, FreeIPA or Active Directory through SSSD can supply the same mapping centrally for many machines.
Because the kernel stores only numbers, a file whose owning UID has no matching account appears in ls -l as a bare number instead of a name. This is common after deleting an account with userdel or when copying archives between systems. The command id shows the UID, primary GID and supplementary groups of the current or named user.
The following table shows how UID ranges are conventionally allocated on modern distributions. The boundaries are configured by UID_MIN and SYS_UID_MAX in /etc/login.defs and may differ on older or customized systems.
| UID range | Purpose | Typical example |
|---|---|---|
| 0 | Superuser with full privileges | root |
| 1 to 999 | System and service accounts | sshd, www-data, systemd-network |
| 1000 to 60000 | Regular human users | First user created at installation |
| 65534 | Unprivileged placeholder account | nobody |
| 100000 and above | Subordinate ranges for containers | Entries in /etc/subuid |
Since kernel 2.4, UIDs are 32-bit values, which allows more than four billion identifiers. Some older tools and file formats still assume 16-bit values, so very large UIDs occasionally expose compatibility bugs.
Real, effective and saved user identifiers
Each Linux process holds several distinct UIDs, and distinguishing them explains how privilege changes work. The kernel uses the effective UID for most permission checks, while the other values record who started the process and which identity it may return to.
| UID type | Meaning | Used for |
|---|---|---|
| Real UID | The user who started the process | Signal permissions and accounting |
| Effective UID | The identity currently in force | Most file and resource access checks |
| Saved set-user-ID | A stored copy of a previous effective UID | Dropping and regaining privileges |
| Filesystem UID | Linux-specific identity for file access | File checks, normally equal to effective UID |
When an executable has the setuid bit set, running it changes the effective UID to the file owner’s UID while the real UID stays the same. This is how passwd can write to /etc/shadow on behalf of an ordinary user. Well-written privileged programs drop privileges permanently with setresuid() as soon as the privileged operation is complete.
Tools such as sudo, su and doas start a new process with a different real and effective UID after authentication and policy checks, typically defined in sudoers. Modern Linux also splits root’s power into capabilities, so a process can hold one specific privilege, such as binding to low ports, without having UID 0.
UID compared with related identifiers
The UID is one of several numeric identifiers in the Linux access model, and each answers a different question. Confusing them leads to incorrect permission troubleshooting.
| Identifier | Identifies | Stored in |
|---|---|---|
| UID | A user account | /etc/passwd, inode owner field |
| GID | A group | /etc/group, inode group field |
| PID | A running process | Kernel process table |
| SID | A Windows security principal | Windows security database |
| Subordinate UID | A mapped user inside a namespace | /etc/subuid |
Unlike a Windows SID, which is globally unique by design, a Linux UID is meaningful only within one system or one directory domain. The same number can belong to different people on two unmanaged machines.
Managing UIDs in practice
Administrators manage UIDs mainly through useradd, usermod and userdel. By default, useradd assigns the next free UID above UID_MIN, but an explicit value can be set with the -u option, which is useful when consistent UIDs across servers are required.
- Keep UIDs consistent across hosts that share files over NFS, rsync or backup systems.
- Avoid reusing the UID of a deleted account, because files it left behind would pass to the new user.
- Run services under dedicated system UIDs instead of root to limit the damage from compromise.
- Change a UID carefully:
usermod -uupdates the home directory, but files elsewhere must be fixed withfindandchown. - Audit accounts with UID 0, because any account with that value has full root power regardless of its name.
UID namespaces, containers and common pitfalls
Linux user namespaces allow a process to have one UID inside a namespace and a different UID on the host. Rootless containers rely on this: a process can be UID 0 inside the container while mapping to an unprivileged subordinate UID such as 100000 on the host, which limits the impact of a container escape.
Most UID problems surface as unexpected ownership or access errors. The table lists the frequent cases and their remedies.
| Symptom | Cause | Fix |
|---|---|---|
| Numbers shown instead of owner names | Orphaned files from a deleted account | Reassign with chown or remove |
| Wrong owner on NFS share | UID mismatch between hosts | Align UIDs or use central directory |
| Container volume not writable | Namespace mapping differs | Adjust subordinate UID mapping |
| Unknown account with root power | Second account with UID 0 | Remove it and investigate compromise |
Stripped to the essentials
A user identifier is the account number Linux gives each user. People see names like alice or bob, but the system itself only remembers numbers. Every file is stamped with the number of its owner, and every running program carries the number of the user it works for.
It is similar to a staff badge number in a large building. The guard does not care about your name, only whether the badge number is allowed through a door. Number 0 is the master key, so it must be protected carefully.
Where it is applied
A research group ran three Linux servers that shared a home directory over NFS. A new member was created on each server separately, and received UID 1004 on one machine and UID 1006 on another. On the second server, her files appeared to belong to a colleague, and she could not save results in her own directory.
The administrator moved all accounts to a central directory service, assigned fixed UIDs to every user, and corrected existing files with find and chown. After the change, every server reported the same owner for each file, and the group added a rule that no UID is ever reused after an account is removed.