Skip to content

id Linux Command Guide

The Linux id command is used to display the user and group information for the current user or a specified username. It shows the user’s uid (user ID), gid (group ID), and groups that the user belongs to. By default, it displays information for the current user. However, you can specify a username as an argument to see information for a different user. This command is useful for identifying the permissions and access levels of a user within a Linux system.

id Syntax:

Terminal window
id [options] [username]

Options:

OptionDescription
-g, —groupPrint only the group ID
-G, —groupsPrint all group IDs
-n, —namePrint a name instead of a number
-u, —userPrint only the user ID

Parameters:

ParameterDescription
usernameSpecify the user to look up

id Command Samples:

Display User and Group IDs

Terminal window
id

This command displays the current user’s UID (User ID) and GID (Group ID).

Display User Information

Terminal window
id username

Replace “username” with the name of the user you want to view information for. This command displays the UID, GID, and groups associated with that user.

Display Group Information

Terminal window
id -g groupname

Replace “groupname” with the name of the group you want to view information for. This command displays the GID of the specified group.

Display Supplementary Group IDs

Terminal window
id -G

This command displays the supplementary group IDs associated with the current user.

Display all User Information

Terminal window
id -a username

Replace “username” with the name of the user you want to view all information for. This command displays UID, GID, groups, and group IDs associated with the specified user.

Display Only the User ID

Terminal window
id -u

This command displays only the UID (User ID) of the current user.

Display Only the Group ID

Terminal window
id -g

This command displays only the GID (Group ID) of the current user.

id FAQ:

How do I use id in Linux?

To use the id command in Linux, execute the following command:

Terminal window
id

How can I display user and group information with id?

You can display user and group information by using the following command:

Terminal window
id <username>

How do I show the group information for a user with id?

To show only the group information for a user, use the id command with the -G option like this:

Terminal window
id -G <username>

How can I display the group names instead of IDs using id?

If you want to display group names instead of IDs, you can run the id command with the -n option:

Terminal window
id -nG <username>

How do I check the group memberships of the current user with id?

To check the group memberships of the current user, you can simply execute the id command without any options:

Terminal window
id

How to display the real and effective user and group IDs using id?

To display both the real and effective user and group IDs, you can use the id command with the -u option:

Terminal window
id -u

Applications of the id command

  • Check user and group information
  • View the effective user and group ID
  • Verify group memberships for a user
  • Display the user’s primary group
  • Show all groups a user belongs to
  • Get the user’s username and user ID
  • Grant or restrict access based on group membership