id
id linux command cheatsheet by Thamizhiniyan C S
Introduction
The id command is used to print real and effective user and group IDs
Syntax
id [OPTION]... [USER]...
Important Flags
-g
Print only the effective group id.
-G
Print all Group ID’s.
-n
Prints name instead of number.
-r
Prints real ID instead of numbers.
-u
Prints only the effective user ID.
–help
Display help messages and exit.
–version
Display the version information and exit.
Examples
idPrint the current user's UID and GID.
id -u rootFind the UID of the user named "root".
id -g rootFind the GID of the user named "root".
id rootFind the UID and all groups associated with the user "root".
id -G rootDisplay the UID and all groups a user "root" belongs to.
id -ng rootDisplay the name instead of numbers for GID of "root".
id -nu rootDisplay the name instead of numbers for UID of "root".
id -nG rootDisplay the name instead of numbers for all groups of "root".
id -r -g rootDisplay the real GID instead of effective GID of "root".
id -r -u rootDisplay the real UID instead of effective UID of "root".
id -r -G rootDisplay the real group IDs instead of effective groups of "root".
Last updated
Was this helpful?