Linux Command #34 – id (Linux OS)

Minimal black and neon-green cover for Linux Command #34 showing the id command with the neutral bitcoin username.

The Linux id command shows the identity Linux uses for a user: the user ID, primary group ID, and every supplementary group the account belongs to. It is a fast, read-only way to answer, “Who is this account, and which group permissions can it use?”

Definition

id is an identity-reporting command. A UID is the number Linux assigns to a user account. A GID is the number Linux assigns to a group. Supplementary groups give the user additional group-based access.

Basic Syntax

id

A typical result looks like this:

uid=1000(bitcoin) gid=1000(bitcoin) groups=1000(bitcoin),27(sudo)
  • uid=1000(bitcoin) means the username is bitcoin and its numeric user ID is 1000.
  • gid=1000(bitcoin) identifies the account’s primary group.
  • groups=... lists the primary group plus supplementary groups. Membership in sudo may allow administrative commands when the system’s sudo policy permits them.

Check Another Account

Add a username to inspect that account without switching users:

id alice

If the account does not exist, id reports that no such user is available.

Video Walkthrough

This short walkthrough demonstrates the id command and its most useful options.

Useful Options

CommandWhat it prints
id -uEffective numeric user ID
id -unEffective username
id -gEffective primary group ID
id -gnEffective primary group name
id -GAll group IDs
id -GnAll group names

The -n option asks for a name instead of a number. Use it with -u, -g, or -G.

whoami vs. id

whoami prints only the current effective username. id provides the broader identity picture: user number, primary group, and supplementary groups. In most ordinary shells, whoami and id -un print the same username.

Practical Troubleshooting

Suppose a technician receives Permission denied while accessing a shared directory. Run:

id
ls -ld /path/to/shared-directory

Compare the user’s groups with the directory’s owner, group, and permission bits. If the required group is absent from the id output, group membership may explain the failure. After an administrator changes group membership, the user may need to sign out and back in before a new session receives it.

Safety Note

id only reads and displays identity information; it does not change accounts, groups, passwords, or permissions. It is safe to run during routine troubleshooting.

Practice Lab

  1. Run id and identify your UID, primary GID, and supplementary groups.
  2. Run id -un and compare the result with whoami.
  3. Run id -Gn and explain what each listed group could control.
  4. If another local username is available, run id username to compare its identity.

Knowledge Check

  • What is the difference between a UID and a GID?
  • Which command prints only group names?
  • Why can group membership affect access even when the username is correct?

Continue the Linux Series

Reference

For the complete option reference, see the GNU Coreutils id manual or run man id in a terminal.

Key Takeaway

Use id to confirm the exact user and group identity Linux will use when evaluating access. It turns a vague permissions problem into concrete UID, GID, and group-membership facts.

3 responses to “Linux Command #34 – id (Linux OS)”

  1. […] previous lesson, Linux Command #34 – id, shows user and group IDs. groups is narrower: it gives you a quick list of group […]

    Like

  2. […] its numeric GID, and supplementary members listed in the group database. This complements both Linux Command #34 – id and the previous groups […]

    Like

Leave a comment