id Linux Command Guide
The Linux id command is used to display the user and group information for the current user or a specified username. It shows the user’s uid (user ID), gid (group ID), and groups that the user belongs to. By default, it displays information for the current user. However, you can specify a username as an argument to see information for a different user. This command is useful for identifying the permissions and access levels of a user within a Linux system.
id Syntax:
Options:
Option | Description |
---|---|
-g, —group | Print only the group ID |
-G, —groups | Print all group IDs |
-n, —name | Print a name instead of a number |
-u, —user | Print only the user ID |
Parameters:
Parameter | Description |
---|---|
username | Specify the user to look up |
id Command Samples:
Display User and Group IDs
This command displays the current user’s UID (User ID) and GID (Group ID).
Display User Information
Replace “username” with the name of the user you want to view information for. This command displays the UID, GID, and groups associated with that user.
Display Group Information
Replace “groupname” with the name of the group you want to view information for. This command displays the GID of the specified group.
Display Supplementary Group IDs
This command displays the supplementary group IDs associated with the current user.
Display all User Information
Replace “username” with the name of the user you want to view all information for. This command displays UID, GID, groups, and group IDs associated with the specified user.
Display Only the User ID
This command displays only the UID (User ID) of the current user.
Display Only the Group ID
This command displays only the GID (Group ID) of the current user.
id FAQ:
How do I use id in Linux?
To use the id command in Linux, execute the following command:
How can I display user and group information with id?
You can display user and group information by using the following command:
How do I show the group information for a user with id?
To show only the group information for a user, use the id command with the -G option like this:
How can I display the group names instead of IDs using id?
If you want to display group names instead of IDs, you can run the id command with the -n option:
How do I check the group memberships of the current user with id?
To check the group memberships of the current user, you can simply execute the id command without any options:
How to display the real and effective user and group IDs using id?
To display both the real and effective user and group IDs, you can use the id command with the -u option:
Applications of the id command
- Check user and group information
- View the effective user and group ID
- Verify group memberships for a user
- Display the user’s primary group
- Show all groups a user belongs to
- Get the user’s username and user ID
- Grant or restrict access based on group membership