Linux id Command: Show User and Group IDs

id checks the user ID (UID), default group ID (GID), and supplementary groups of the current process or a specified user. It is a starting point for verifying the actual group information of the current account when checking file access permissions.

What is the id command?

When run without arguments, it prints the user and group information of the current process. If a user is specified, it looks up that user's information in the account database. For processes where the effective UID and original UID differ, -r can be used to separately check the original ID.

Basic syntax

id [option] [user]

The installed implementation and options may vary depending on the distribution. Check the description on your system with man id.

Examples

Check current user and group

Displays UID, default GID, and supplementary groups together.

id

Query another account

The group composition of the account can be queried, but permission is not switched to that account.

id alice

Extract only names or numbers

-u prints the valid UID, -un prints the corresponding name.

id -u
id -un

Reading UID, GID, and supplementary groups

id displays the user identification number (UID), primary group number (GID), and supplementary groups all at once. The numbers and names vary by system.

id

Example output:

uid=1000(alice) gid=1000(alice) groups=1000(alice),27(sudo)

In this example, alice's primary group is shown after gid=, not next to the UID. Supplementary groups affect file access permissions and administrator rights. If a script only needs the numeric UID, use id -u; if you only need the current user's group names, use id -Gn.

Main Options and Format

Options/Format Description
-u Displays only the user ID.
-g Displays only the valid primary group ID.
-G Displays all group IDs.
-n Displays as names with -u, -g, -G.
-r Displays the real ID instead of the valid ID with -u, -g, -G.

Precautions when using

If you have just changed the user's group membership, the list of groups in an already open login session may differ from the results of a query to the account database. When investigating permission issues, run id directly in the session where the problem occurred. id alice does not change the privileges of the current session.

Frequently Asked Questions

What are the UID and GID displayed in id?

UID is the user identification number, and GID is the primary group identification number. Additional groups are displayed in the groups entry that follows.

Official Documentation

The exact behavior of the options and differences between implementations can be checked in the official documentation related to id.

More in This Category
Linux type Command: Identify How a Command Is Resolved

Linux type Command: Identify How a Command Is Resolved

Learn how to use the Linux type command to identify aliases, functions, built-ins, keywords, and executable paths, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux more Command: View Text One Screen at a Time

Linux more Command: View Text One Screen at a Time

Learn how to use Linux more to read text one screen at a time, move and search interactively, start at a line or pattern, and choose between more and less.

Linux groups Command: Show a User's Group Memberships

Linux groups Command: Show a User's Group Memberships

Learn how to show a User's Group Memberships with the Linux groups command, including practical examples, key options, and important precautions.

Linux dnf Command: Manage RPM Distribution Packages

Linux dnf Command: Manage RPM Distribution Packages

Learn how to manage RPM Distribution Packages with the Linux dnf command, including practical examples, key options, and important precautions.

Linux fdisk Command: Inspect and Edit Disk Partitions

Linux fdisk Command: Inspect and Edit Disk Partitions

Learn how to inspect and Edit Disk Partitions with the Linux fdisk command, including practical examples, key options, and important precautions.

Linux Tutorial / What Is Linux? Understanding the Kernel, Distributions, and Open Source

Linux Tutorial / What Is Linux? Understanding the Kernel, Distributions, and Open Source

Understand how the Linux kernel differs from a distribution, what user space and open source mean, and how to check your system's kernel and distribution versions.

Linux cd Command: Change the Current Directory

Linux cd Command: Change the Current Directory

Learn how to use the Linux cd command to move between directories using absolute, relative, home, and previous paths, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux hostnamectl Command: Show and Change the Host Name

Linux hostnamectl Command: Show and Change the Host Name

Learn how to show and Change the Host Name with the Linux hostnamectl command, including practical examples, key options, and important precautions.

Linux Tutorial / Standard Input, Output, Redirection, and Pipes

Linux Tutorial / Standard Input, Output, Redirection, and Pipes

Understand standard input, output, and error; practice file redirection and pipes; and learn why overwrite risk and redirection order matter.

Linux Tutorial / Manage Files and Directories: Create, Copy, Move, and Delete

Linux Tutorial / Manage Files and Directories: Create, Copy, Move, and Delete

Practice creating, copying, renaming, moving, and deleting files and directories in a dedicated folder while checking each result safely.