id flags & options
Basic usage
Show UID, GID, and group memberships for the current user.
id
Specific user
Show info for a different user.
id www-data
-u, --user
Print only the effective user ID.
id -u
-g, --group
Print only the effective group ID.
id -g
-G, --groups
Print all group IDs the user belongs to.
id -G
-n, --name
Print names instead of numeric IDs. Use with -u, -g, or -G.
id -un
id -Gn
-r, --real
Print the real ID instead of the effective ID.
id -ru
Check if running as root
[ "$(id -u)" -eq 0 ] && echo "Running as root"