The id command in Linux is used to find out the user and group names along with numeric user IDs of the current user or any other user in the server. The command is useful to find the following information:
1. Username and real user ID
2. Specific user UID
3. UIDs and all groups associated with a user
4. List of all groups a user belongs to
5. The security context of the current user.
Syntax:
Options:
-g: Print only effective group ID
-G: Prints all group IDs
-n: Prints names instead of numbers
-r: Prints real IDs instead of numbers
-u: Prints only effective user IDs
-help: Displays help messages and exits
-version: Displays the version information and exits
Examples:
1. To print self-id without any options:
2. To find a specific user ID (Assuming we are finding the user ID for a user named master):
3. To find the UID and all groups associated with a username (Assuming we are finding them for a user named master):
4. To find all the groups a user belongs to (Assuming we are finding it for a user named master):
5. To display name instead of number (Assuming we are finding it for a user named master):
5. To display read ID instead of effective ID (Assuming we are finding it for a user named master):
Comments