🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

id Command

Beginner User Management man(1)

Print user and group IDs

👁 7 views 📅 Updated: Mar 15, 2026
SYNTAX
id [OPTION]... [USER]

What Does id Do?

id displays user and group identity information. Without arguments, it shows the current user's UID, GID, and all group memberships. With a username argument, it shows that user's information.

id is essential for verifying user identity, checking group memberships, debugging permission issues, and confirming that group changes took effect.

The output includes the numeric UID and GID along with their names, and all supplementary groups the user belongs to.

Options & Flags

OptionDescriptionExample
-u Print only effective user ID id -u
-g Print only effective group ID id -g
-G Print all group IDs id -G
-n Print name instead of number (with -u, -g, -G) id -un
-r Print real (not effective) ID id -ru
username Show info for specific user id www-data

Practical Examples

#1 Show current identity

Displays UID, GID, and all groups for the current user.
$ id
Output: uid=1000(user) gid=1000(user) groups=1000(user),27(sudo),998(docker)

#2 Show specific user

Shows identity info for the www-data user.
$ id www-data
Output: uid=33(www-data) gid=33(www-data) groups=33(www-data)

#3 Get username

Prints just the effective username.
$ id -un
Output: user

#4 Get numeric UID

Prints just the numeric user ID.
$ id -u
Output: 1000

#5 List all groups

Lists all group names the current user belongs to.
$ id -Gn
Output: user sudo docker www-data

#6 Check group membership

Checks if a user is in the sudo group.
$ id -Gn jdoe | tr " " "\n" | grep sudo && echo "Has sudo"

Tips & Best Practices

Verify group changes: After usermod -aG, run id username to verify the group was added. The user must log out/in for groups to take effect in their session.
Real vs effective ID: Effective ID determines permissions. Real ID is the original user. They differ when running SUID programs or using sudo.
Current session vs stored groups: id shows stored groups from /etc/group. Your current session may differ until re-login. Use groups command for session groups.

Frequently Asked Questions

How do I check what groups I am in?
Use id -Gn for group names or id for full details. Or simply: groups.
How do I find a user UID?
Use id -u username for numeric UID, or id username for full identity information.
Why does id show a group but I still get permission denied?
Group changes require re-login. Log out and back in, or use newgrp groupname for the current session.

Master Linux with Professional eBooks

Curated IT eBooks covering Linux, DevOps, Cloud, and more

Browse Books →