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 Tutorial / Find Files and Commands with find, locate, which, and whereis

Linux Tutorial / Find Files and Commands with find, locate, which, and whereis

Compare find and locate for file searches, then use which, whereis, and Bash type to distinguish executable paths from shell command resolution.

Linux touch Command: Create Files and Change Timestamps

Linux touch Command: Create Files and Change Timestamps

Learn how to use the Linux touch command to create empty files and change access or modification timestamps, including reference times, date formats, and symlink handling.

Linux mkfs Command: Create a New Filesystem

Linux mkfs Command: Create a New Filesystem

Learn how to create a New Filesystem with the Linux mkfs command, including practical examples, key options, and important precautions.

Linux journalctl Command: Read systemd Logs

Linux journalctl Command: Read systemd Logs

Learn how to read systemd Logs with the Linux journalctl command, including practical examples, key options, and important precautions.

Linux chgrp Command: Change a File's Group

Linux chgrp Command: Change a File's Group

Learn how to change a File's Group with the Linux chgrp command, including practical examples, key options, and important precautions.

Linux Tutorial / PID and PPID Explained: Find and Manage Processes

Linux Tutorial / PID and PPID Explained: Find and Manage Processes

Understand what PID and PPID mean, inspect parent-child process relationships with ps and pgrep, and safely terminate a process you started yourself.

Linux lscpu Command: Inspect CPU Architecture and Cores

Linux lscpu Command: Inspect CPU Architecture and Cores

Learn how to inspect CPU Architecture and Cores with the Linux lscpu command, including practical examples, key options, and important precautions.

Linux printenv Command: Print Environment Variable Values

Linux printenv Command: Print Environment Variable Values

Learn how to use the Linux printenv command to print all environment variables or selected variable values, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux Tutorial / Inspect, Pause, and Stop Processes

Linux Tutorial / Inspect, Pause, and Stop Processes

Inspect Linux processes with ps, top, and pgrep, then safely pause, resume, and terminate a practice process while distinguishing shell jobs from services.

Linux history Command: Review and Reuse Shell Command History

Linux history Command: Review and Reuse Shell Command History

Learn how to use the Linux history command to review, search, reuse, and manage shell command history, with essential options, practical examples, output interpretation, and common troubleshooting tips.