$linuxjunkies
>

id(1)

Print user and group IDs and names for the current user or a specified user.

UbuntuDebianFedoraArch

Synopsis

id [OPTION]... [USER]

Description

The id command displays the user ID (UID), group ID (GID), and all group memberships for the current user or a named user. It shows both numeric IDs and human-readable names, making it useful for debugging permission issues and understanding user roles.

When run without arguments, id shows the effective UID and GID. Use options to display only specific information or to show the real (login) IDs instead of effective ones.

Common options

FlagWhat it does
-uprint only the effective user ID (UID)
-gprint only the effective group ID (GID)
-Gprint all group IDs (including supplementary groups)
-nprint names instead of numbers (use with -u, -g, or -G)
-rprint real IDs instead of effective IDs (for setuid/setgid processes)
-zdelimit output fields with NUL characters instead of whitespace
--helpdisplay help message and exit
--versiondisplay version information and exit

Examples

show UID, GID, and all group memberships for the current user

id

show UID, GID, and group memberships for the user named john

id john

print only the effective UID as a number

id -u

print only the effective username (not the UID)

id -un

list all group IDs (including supplementary groups) that the current user belongs to

id -G

list all group names (including supplementary groups) that the current user belongs to

id -Gn

print the real (login) UID, useful in setuid processes to see the original user

id -r -u

show UID, GID, and group memberships for the root user

id root

Related commands