Linux ID command-displays user ID and group ID information

Source: Internet
Author: User

To log in to a computer, we need a username. A user name is an identity that can be recognized by a computer. Based on this, the computer applies a series of rules to people who log on with this user name. Under the Linux system, we can use the ID command.

What is the ID command

The ID command can display a true valid user ID (UID) and group ID (GID). The UID is a single identity for a user. The group ID (GID) corresponds to multiple UID.

How to use the ID command

The ID command has been preinstalled on most Linux systems by default. To use it, just enter the ID in your console. The input ID without an option is shown below. The results are used by active users.

$ id

How to read the output:
    • UID Number of user Pungki = +, GID number =
    • User Pungki is the following group member:

      Pungki 's GID number =
      GID number of adm = 4
      cdrom 's GID number =
      sudo 's GID number =
      GID number for dip =
      Plugdev 's GID number =
      Lpadmin 's GID number = 108
      Sambashare 's GID number = 124

Use ID with option

The ID command can use some options. Here are some options that are useful in everyday use.

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

To do this, we can use the-a option

$ id-a

Output all different group IDs (valid, True, and supplemental)

We can do this by using the- g option.

$ id-g

The result will only show the GID number. You can compare it with the /etc/group file. Here 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

Only valid group IDs are output by using the- g option.

$ id-g

Output specific user information

We can output the UID and GID associated with specific user information. You only need to follow the ID command followed by the user name.

$ id Leni

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

Summarize

The ID command is useful when we want to know the UID and GID of a user. Some programs may require uid/gid to run. The ID makes it easier to find the UID of the user as a GID without having to search in the/etc/group file. As always, you can enter the ID of the man ID in the console to get more details.

Linux ID command-displays user ID and group ID information

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.