HxHippy

id

Print real and effective user and group IDs

Overview

The id command prints user and group information for the specified USER, or (when USER is omitted) for the current user.

Syntax

id [OPTION]... [USER]

Common Options

-u, --user

Print only the effective user ID.

-g, --group

Print only the effective group ID.

-G, --groups

Print all group IDs (effective).

-n, --name

Print name instead of ID number (for use with -u, -g, -G).

-r, --real

Print real ID instead of effective ID (for use with -u, -g, -G).

-Z, --context

Print only the security context of the process (e.g., SELinux).

-z, --zero

Delimit entries with NUL characters, not whitespace; useful with -G, -g, or -u for scripting.

Examples

$ id

Displays all user and group ID information for the current user (UID, GID, groups).

$ id some_user

Displays all user and group ID information for some_user.

$ id -u

Prints the effective user ID number of the current user.

$ id -un

Prints the name corresponding to the effective user ID of the current user.

$ id -g

Prints the effective group ID number of the current user.

$ id -gn

Prints the name corresponding to the effective group ID of the current user.

$ id -G

Prints all effective group ID numbers the current user belongs to.

$ id -Gn

Prints all effective group names the current user belongs to.

$ id -urn another_user

Prints the real user name of another_user.

user idgroup iduidgideffective idreal ididentityid