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

Flag
Description

-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

Command
Description
id

Print the current user's UID and GID.

id -u root

Find the UID of the user named "root".

id -g root

Find the GID of the user named "root".

id root

Find the UID and all groups associated with the user "root".

id -G root

Display the UID and all groups a user "root" belongs to.

id -ng root

Display the name instead of numbers for GID of "root".

id -nu root

Display the name instead of numbers for UID of "root".

id -nG root

Display the name instead of numbers for all groups of "root".

id -r -g root

Display the real GID instead of effective GID of "root".

id -r -u root

Display the real UID instead of effective UID of "root".

id -r -G root

Display the real group IDs instead of effective groups of "root".

Last updated

Was this helpful?