42. User Information - IDs, Group IDs, Names, and so on
Contents
The Linux core toolset provides us with some commands to view user-related information.
Print User Identity
We can use the id command to view the user’s ID, name, user’s group ID and name, etc:
|
|

By default, id output the real user ID, real group ID, effective user ID (if different from the real user ID), effective group ID(if different from the real group ID), and supplement group IDs
Print the User ID
If we add the -u option, the command will only output the user’s ID:
|
|

Output the user's ID
Print the Group ID
If we add the -g option, the command will only output the group ID:
|
|

Output the user's group ID
Print the Group ID and the Supplementary Groups
If we add the -G option, the command will only output the supplementary groups’ ID:
|
|

Output the user's group ID and supplementary groups
Print the Name, Group Name, Supplementary Group Name of the User
If we add the -un, -gn or -Gn option, the command will only output the user’s name, group name, and supplementary group’s name:
|
|

Output the user's name, group name and supplementary group name
Print the Real ID, Real Group ID, Real Supplementary Group ID of the User
If we add the -ur, -gr or -Gr option, the command will only output the user’s real ID, group real ID, and supplementary group’s real ID:
|
|

Output the user's real ID, group real ID, and supplementary group's real ID
Print the Security Context of the User
If we add the -Z option, the command will only output the user’s security context:
|
|

Output the user's security context
Print Current Login Name
We can use logname command to display the user name of the current login:
|
|

Output the user's login name
Print Who is Currently Logged in
We can use who command to display the logged in user names and other login details:
|
|

Output the information about users who are currently logged on
Print Effective User ID
We can use whoami command to display the effective user ID:
|
|

Output the effective user ID
Print Group Names the User Belongs to
We can use group command to display the user’s belonging group names:
|
|

Output the user's beloging groups
Or we can specify a user name to view the group to which the user belongs:
|
|
Print Users Names
We can use users command to display the logged in users’ names:
|
|

Output the users' name
Print User Details With finger
We can use finger command to display the user names currently logged in:
|
|

Output the details of the specified user
References 20 User information
Author Dong Chen
LastMod Thu Mar 14 2019