Javatpoint Logo
Javatpoint Logo

Linux id Command

Linux id command is used to print the genuine and effective user ID and group ID. A user ID (UID) is a particular user identity, whereas group IDs (GIDs) can contain more than one user's identity. This command is a useful tool for user management.

Tracing the names of users and groups, and their corresponding UIDs and GIDs is a complex task for the new user. This is important for user management. In such cases, the id command will help us.

Syntax:

Options:

The supported options by the id command are as following:

  • -a: It is used to ignore the compatibility with other versions.
  • -Z, --context: It is used to print only the security context of the process.
  • -g, --group: It is used to print only the effective GID.
  • -G, --groups: It is used to print all group Ids.
  • -n, --name: It is used to print a name instead of a number.
  • -r, --real: It is used to print the real ID instead of the effective ID, with -ugG
  • -u, --user: It is used to print only the effective UID.
  • -z, --zero: It is used to delimit entries with NULL characters, except the whitespace;
  • --help: It used to display the help documentation and exit.

How to use it?

The id command is a built-in utility; therefore, we do not need to install any additional tools to use it. The 'id' command can be used without arguments. Execute the command as follows:

From the above command, the output will use the active user. Its default behavior is as follows:

Linux id Command

From the above output, we can see there are several fields. The first two fields are the UID and GID for the user 'javatpoint'. Whereas, rest are the groups with their respective GID that the 'javatpoint' is a part of.

Let's see some other useful examples of the id command.

Find a specific user's UID

To find a user's specific user ID, execute the command with the '-u' option. For example. Find the user Id for the user 'javatpoint', execute the command as follows:

Consider the below output:

Linux id Command

Find a specific user's GID

To find a specific user's GID, execute the command with the '-g' option. For example, to find the GID for the user 'javatpoint', execute the command as follows:

Consider the below output:

Linux id Command

Display the real GID and UID instead of effective

We can display the real UID and GID instead of effective ids by executing the command with the '-r' option.

To display the real UID and GID for the user 'javatpoint', execute the following commands:

Consider the below output:

Linux id Command

Display all the different Group IDs

To display all the different GIDs, execute the command with the '-G' option as follows:

Consider the below output:

Linux id Command

Display effective GROUP ID

To display only the effective GID, execute the command with the '-g' option as follows:

Consider the below output:

Linux id Command

Getting Help

If you get stuck during the use of the id command, you can take help from your terminal. You can read the manual page and help documentation. To take help, execute the below command:

The above command will display the help documentation as follows:

Linux id Command

To read the manual, execute the command as follows:

It will display the manual as given below:

Linux id Command
Next TopicLinux Files





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA