id

Display user identity

id [user]
id -A|-M
id -F|-P|-p [user]
id -G [-n] [user]
id -g|-u [-nr] [user]

Outputs the user and group names and numeric IDs, of the calling process, to the standard output.
If the real and effective IDs are different, both are ooutput, otherwise only the real ID is output.

If a user (login name or user ID) is specified, the user and group IDs of that user are output ( the real and effective IDs are assumed to be the same).

-F full name of the user.
-u effective user ID
-g effective group ID
-r with -g and -u real ID
-G group IDs (effective, real and supplementary) as white-space separated numbers.
20 12 61 79 80 81 98 703 702 701 33 100 204 250 395 398 101 400
-n name of the IDs for -G, -g and -u
IDs that cannot be mapped into names are displayed as numbers.
id -G -n
staff everyone localaccounts _appserverusr admin _appserveradm _lpadmin …
dgerman:********:501:20::0:0:Dennis German:/Users/dgerman:/bin/zsh
-P /etc/password file entry.
-p On seperate lines:
If the user name returned by getlogin is different from the login name referenced by the user ID, login and the user name returned by getlogin is output.
If the effective user ID is different from the real user ID, euid and the real user ID is output as a name.
If the effective group ID is different from the real group ID, rgid and the real group ID is output as a name.
groups and the list of groups to which the user belongs is output as names.
> id -p
uid dgerman
groups  staff everyone localaccounts _appserverusr admin _appserveradm _lpadmin …
-A process audit user ID and other process audit properties, which requires privilege.
Example:
id -A
auid=501
mask.success=0xffffffff
mask.failure=0xffffffff
asid=100006
termid_addr.port=0x03000002
termid_addr.addr[0]=0x00000000
termid_addr.addr[1]=0x00000000
termid_addr.addr[2]=0x00000000
termid_addr.addr[3]=0x00000000

Example:output is one string. Edited here for your viewing pleasure.

uid=501(eman) gid=20(staff) 
groups=
 12(everyone),
 61(localaccounts),
 20(staff),
 80(admin),
250(_analyticsusers),
204(_developer),
 98(_lpadmin), 100(_lpoperator),
395(com.apple.access_ftp),
400(com.apple.access_remote_ae)
398(com.apple.access_screensharing),
…
The historic groups(1) command is equivalent to id -Gn [user].

Linux version does not provide -A, -F, -P, -p, it does include:

-Z
--context
with SELinux output the security context of the current user
-G
--groups
output all group IDs
-z
--zero
delimit entries with NUL characters