Basics

Linux id command

Show user and group IDs for the current user or another account.

Availability: Common Linux commands; shell built-ins and external implementations may differ by distribution.中文

Syntax

id [OPTION]... [USER]

Examples

Show IDs and groups for the current user.

id

Print the account name associated with the real user ID.

id -un alice

Parameters, options and clauses

Option / clauseDescription
-u, --userPrint only the user ID.
-g, --groupPrint only the primary group ID.
-G, --groupsPrint all group IDs.
-n, --nameShow a name instead of a numeric ID; combine with -u, -g or -G.
-r, --realShow the real ID rather than the effective ID.
Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory