Linux id command-Display User id and group id information

Source: Internet
Author: User

To log on to a computer, we need a user name. A user name is an identity that can be recognized by a computer. Based on this, the computer will apply a series of rules to the login users using this user name. In Linux, we can use the id command.

What is the id command?

The id command can display the real and valid user ID (UID) and group ID (GID ). UID is a single identity for a user. The Group ID (GID) corresponds to multiple UIDs.

How to Use the id command

The id command is pre-installed in most Linux systems by default. To use it, you only need to enter the id in your console. The input id without option is displayed as follows. Active users are used in the results.

$ Id

How to read the output:
  • User pungki UID number = 1000, GID number = 1000
  • Pungki is a member of the following group:

    Pungki's GID number = 1000
    Adm's GID number = 4
    Cdrom GID number = 24
    Sudo's GID number = 27
    Dip's GID number = 30
    GID Number of plugdev = 46
    GID of lpadmin = 108
    Sambashare's GID number = 124

Use id with options

The id command can use some options. The following are some useful options for daily use.

Print the username, UID, and all groups to which the user belongs

To do this, we can use the-a option.

$ Id-

Output all different group IDs (valid, true, and supplemented)

We can use the-G option.

$ Id-G

Only the GID number is displayed. You can compare it with the/etc/group file. The following is an example of the/etc/group file:

root:x:0:daemon:x:1:bin:x:2:sys:x:3:adm:x:4:pungkifax:x:21:voice:x:22:cdrom:x:24:pungkifloppy:x:25:tape:x:26:sudo:x:27:pungkiaudio:x:29:pulsedip:x:30:pungkiwww-data:x:33:backup:x:34:operator:x:37:sasl:x:45:plugdev:x:46:pungkissl-cert:x:107:lpadmin:x:108:pungkisaned:x:123:sambashare:x:124:pungkiwinbindd_priv:x:125:
Only valid group IDs are output.

Use the-g option to output only valid group IDs.

$ Id-g

Output specific user information

We can output UID and GID related to specific user information. You only need to follow the user name after the id command.

$ Id leni

The above command prints the UID and GID of the user leni.

Summary

The id command is very useful when we want to know the UID and GID of a user. Some programs may need UID/GID to run. Id makes it easier for us to find the user's UID with GID without searching in the/etc/group file. As usual, you can enter man id in the console to go to the id manual page for more details.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.