A complete guide to the id command in Linux
A simple, practical explanation suitable for beginner to intermediate levels
What exactly does the id command show?
In Linux, every user has a numeric identifier (UID), and every group has its own numeric identifier (GID). These values form the foundation of the entire permission system and file ownership rules.
The id command is designed for this purpose: it quickly and directly tells you what UID and GID a user has, and which groups they belong to.
If you run it without any arguments:
The output includes three things:
- The UID of the current user
- The GID of the user’s primary group
- A list of all the groups the user is a member of
This information is essential for understanding permission errors or checking access levels.
To get information about any other user, just write the username after the command, for example:
This command always works without needing sudo.
Useful id options that actually matter
Along with the general output, id has several important switches that are widely used in system management, scripting, and debugging.
1) Show numeric UID
Output: only the UID of the current user Useful for scripts and quick identity checks.
2) Show numeric GID
Output: only the GID of the user’s primary group.
3) Show real UID and GID (Real IDs)
Sometimes UID and GID are not the “effective” ones — for example, sudo can change them. To see the real values:
These are important when you're investigating why a program or service behaves differently than expected.
4) Show all GIDs a user belongs to
This prints only the numeric group IDs.
If you want the output as group names:
Both of these are extremely important for checking user permissions, especially on a multi-user server.
A practical look: When is id actually useful?
In real-world usage, id helps in these situations:
1) Diagnosing “Permission Denied”
When you can’t open a file or run a program, the first step is checking who you are and which groups you belong to.
2) Inspecting users created on a server
For example:
To find out what access each service user has.
3) Writing scripts
When a script needs to ensure it’s being run by a specific user — for example, only root:
4) Checking user groups for sudo or network access
Membership in groups like wheel, docker, video, network can directly affect system behavior.
Summary
The id command is one of the simplest Linux tools, but it’s always the first step in solving permission and ownership issues. With just a few switches, you can quickly find out:
- What UID and GID a user has
- Which groups they belong to
- Their real and effective identities
All of this works without sudo and without installing any additional tools.
Comments
Be the first to share your thoughts.