Last Updated : 05 Sep, 2024
The 'id' command in Linux is a powerful tool used to display user and group names along with their numeric IDs (User ID - UID or Group ID - GID) of the current user or any specified user on the system. This command is particularly useful for system administrators and users who need to verify user identities and associated permissions.
What does the 'id' Command Do?This command is useful to find out the following information as listed below:
id [OPTION]… [USER]
Options:
'id' command Examples in LinuxNote: Without any OPTION it prints every set of identified information i.e. numeric IDs.
Let us look at some of the examples of 'id' command in Linux to better understand the concept.
1. To print your own 'id' without any OptionsTo display your own user and group IDs, simply run:
id
The output shows the ID of current user UID and GID.
2. To find a specific users 'id'Now assume that we have a user named master, to find his UID we will use the command:
id -u master
This will display only the UID of the specified user.
3. To find a specific users GIDAgain assuming to find GID of master, we will use the command:
id -g master
This option will show the effective group ID of the user.
4. To find out UID and all groups associated with a usernameIn this case we will use the user "master" to find UID and all groups associated with it, use command:
id master5. To find out all the groups a user belongs to
Displaying the UID and all groups a user "master" belongs to:
id -G master6. To display a name instead of numbers
By default the 'id' command shows us the UDI and GID in numbers which a user may not understand, with use of '-n' option with '-u', '-g' and '-G'. Use command(s):
id -ng master7. To display real id instead of effective id
or
id -nu master
or
id -nG master
To show the real id with the use of '-r' option with '-g', '-u' and '-G, use command(s):
id -r -g masterConclusion
id -r -u master
id -r -G master
By mastering the 'id' command and understanding its various options, you can enhance your ability to manage and troubleshoot user permissions on Linux systems. This command is a key tool in your Linux toolkit if you’re a system administrator or even a casual user.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4