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:
|
|
Print the User ID
If we add the -u option, the command will only output the user’s ID:
|
|
Print the Group ID
If we add the -g option, the command will only output the 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:
|
|
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:
|
|
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:
|
|
Print the Security Context of the User
If we add the -Z option, the command will only output the user’s security context:
|
|
Print Current Login Name
We can use logname command to display the user name of the current login:
|
|
Print Who is Currently Logged in
We can use who command to display the logged in user names and other login details:
|
|
Print Effective User ID
We can use whoami command to display the effective user ID:
|
|
Print Group Names the User Belongs to
We can use group command to display the user’s belonging group names:
|
|
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:
|
|
Print User Details With finger
We can use finger command to display the user names currently logged in:
|
|
References 20 User information
Author Dong Chen
LastMod Thu Mar 14 2019