Print real and effective user and group IDs.
id [OPTION]... [USER]...
-a Compatibility option; ignored.
-Z, --context Print only the security context of the process.
-g, --group Print only the effective group ID.
-G, --groups Print all group IDs.
-u, --user Print only the effective user ID.
-z, --zero Delimit entries with NUL characters instead of whitespace.
--help Display help and exit.
--version Output version information and exit.
The following options are valid only when used with -u, -g, or -G:
-n, --name Print names instead of numbers.
-r, --real Print real IDs instead of effective IDs.
USER (optional): One or more usernames; defaults to the current user.
Returns 0 on success, non-zero on failure.
[root@localhost ~]# id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
Explanation: User "root" has UID = 0 and GID = 0. User "root" is a member of the following groups:
Print username, UID, and all groups for a user:
[root@localhost ~]# id -a
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
Output all different group IDs (effective, real, and supplementary):
[root@localhost ~]# id -G
0 1 2 3 4 6 10
Only output the effective group ID:
[root@localhost ~]# id -g
0
Output information for a specific user:
[root@localhost ~]# id www
uid=500(www) gid=500(www) groups=500(www)
id makes it easy to find these without searching /etc/passwd or /etc/group manually.GNU coreutils package. For more info, see man 1 id or info coreutils 'id invocation'.