Linux id Command Ubuntu 18.04 LTS – Debian 10
id command in Linux is using to find out user or group name and numeric ID (UID and group ID) of the current user and any other user in the server. This command is useful to find out the following information’s as list below:
- User name and real user id.
- Find out the specific User UID.
- Show the UID and all groups associated with a user.
- List out all the groups a user belongs to.
- Display security context of the current user.
If you are new to system administration in Linux Operation System, your gradually learn that user management is an important aspect of your working.
The Linux command line the offers several “command-line” utilities for this purpose, and one’s of them is the id command.
In this my article, we will discussion the basics of this tool use some easly to understand exampling.
However, before that, it’s worth mentioning that all examples in this tutorial have been tested on an Ubuntu 18.04 LTS machine and Debian 10.
Linux id command
The id command shows you the real and the effective user or group IDs of a given user. Following is its syntax:
id [OPTION]… [USERNAME]
And here how the tool man pages explains it:Linux id Command
Print user and group information for the specified USERNAME, or (when USERNAME omitted) for the current user.
The following are some “Q&A-styled” examples that should give you a good idea on how the id command works.
How to using “id command?”
The basic usage is easy – all you have to do is to execute ‘id‘ with the username for which you want to access the information.
So you can see the output consists of several fields. The first two entries are “user” or “group ID” with ‘himanshu‘, while the rest are the groups that the user ‘himanshu‘ is part of, along with the respective group ID.
that if you don’t pass any username as an argument to the id command, the tool assumes the current user as the one for which you want the information.
How to make id print only group ID?
This can be achieved using the -G command-line option. For example:
id -G himanshu
How to make id print only effective group ID?
This can be achieved use the “-g command” line option.
id -g himanshu
How to make id print only effective user ID?
Similar to the previous example, this can be achieved using the -u command-line option.
id -u himanshu
- How to make id print real ID instead of effective ID?
To make the id command print real ID, use the -r command-line option. This option can be combined with the -u, -g, and -G command-line options.
id -ur himanshu
The id command is easly to understand and using. The number of command-line options it offers is also limited, and we’ve discussed the majority of them here.
Once you are done practicing these, head to the tool’s (View) to learn more about it.
This article is adapted from the official website of howtoforge.com and this is the overall authority of our site to only forward helpful articles.