commands
id — inspect user and group identity
Reports identity and group membership. With no USER, describes the current process identity; -u selects effective UID, -g effective GID, -G supplementary and primary groups, -n names with selected ID option. Read-only; zero on success, nonzero on error. Example assumes a fresh permissions lab fixture.
Formal Syntax & Structure
linux syntaxlinux
id [OPTION] [USER]Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| -u | option | effective user ID |
| -g | option | effective group ID |
| -G | option | group IDs |
| -n | option | names |
| USER | operand | optional account |
Return Value
exit status and output
Reports identity and group membership. With no USER, describes the current process identity; -u selects effective UID, -g effective GID, -G supplementary and primary groups, -n names with selected ID option. Read-only; zero on success, nonzero on error.
Working Example
Example Snippetlinux
test "$(id -u)" -ne 0 && printf "ordinary-user\n"