id command in Linux with examples (original) (raw)

Last Updated : 18 May, 2026

The id command in Linux is used to display a user’s identity information, including the user name, User ID (UID), Group ID (GID), and group memberships. It is commonly used by system administrators to verify user permissions, troubleshoot access issues, and audit user accounts.

Example: Display Identity of the Current User

**Command:

id

**Output:

**Note: Without any options, it prints all identity information (UID, GID, and groups)

Common Options of id Command

**Syntax:

id [OPTION]… [USER]

**Options:

1. To find a specific user's GID

**Command:

id -g master

Again assuming to find GID of master. This option will show the effective group ID of the user.

**Output:

2. List All Groups a User Belongs To

**Command:

id -G master

**Output:

G1-3

3. Find the UID of a Specific User

**Command:

id -u master

**Output:

4. To find out UID and all groups associated with a username

In this case we will use the user "master" to find UID and all groups associated with it.

**Command:

id master

**Output:

5. To display a name instead of numbers

By default the 'id' command shows us the UID and GID in numbers which a user may not understand, with use of '-n' option with '-u', '-g' and '-G'.

**Syntax:

id -ng master
or
id -nu master
or
id -nG master

**Output:

6. To display real id instead of effective id

To show the real id with the use of '-r' option with '-g', '-u' and '-G'.

**Syntax:

id -r -g master
id -r -u master
id -r -G master

Differences Between id and groups Command

Both id and groups are used to check user and group information in Linux, but they serve different purposes:

Aspect id Command groups Command
Purpose Displays complete user identity information Displays group memberships only
Output UID, GID, all groups (numeric or names) Group names only
User Details Shows user ID and group IDs Does not show UID or GID
Real vs Effective IDs Supports real and effective IDs (-r) Not supported
Script Usage Better for scripting and audits Better for quick checks
Output Format Structured and detailed Simple and readable

When to Use id

**Example:

id username

When to Use groups

**Example:

groups username