Linux id command

The id command in Linux is used to display user and group identity information. It provides detailed information about the current user or specified user, such as user ID (UID), group ID (GID), and group memberships.

The basic syntax of the id command is as follows:

id [options] [username]

Here’s an explanation of the components:

  • id: The command itself.
  • [options]: Optional flags that modify the behavior of the command.
  • [username]: Optional username to retrieve information for. If not specified, it displays information for the current user.

Here are some commonly used options with the id command:

  • -u or --user: Display only the user ID (UID).
  • -g or --group: Display only the group ID (GID).
  • -G or --groups: Display the group IDs (GIDs) and group names that the user is a member of.
  • -n or --name: Display the user or group name instead of the ID.
  • -r or --real: Display the real user ID instead of the effective user ID.


  1. Display user and group IDs for the current user:


uid=1000(john) gid=1000(john) groups=1000(john),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),116(lpadmin),126(sambashare)
  1. Display only the user ID (UID):
id -u


  1. Display the group IDs (GIDs) and group names for the specified user:
id -Gn alice


alice : alice adm cdrom sudo dip plugdev lpadmin sambashare

The id command provides useful information about user and group identities, which is helpful for system administration, user management, and troubleshooting purposes in Linux.