Learn a Linux command every day (55): ID

Time:2021-7-29

Learn a Linux command every day (55): ID

Yesterday’s recommendation:Learn a Linux command every day (54): W

Command introduction

The ID command is used to view the uidgid of the user and the user group to which the user belongs.

It should be noted that the uid is unique in the system and the identity of the user, but the GID can correspond to multiple UIDs (a simple understanding is that a user can join multiple user groups).

Syntax format

id  [ Options] [user name]

Option description

-g   # Displays the ID of the group to which the user belongs
-G    # Displays the ID of the additional group to which the user belongs
-n   # Displays the name of the user, group or additional group
-r   # Display actual ID
-u   # Display user ID
-Z    # Print only the security context of the current user
-help    # print the help information
-version       # Print version information

Application examples

[[email protected] ~]# id
uid=0(root) gid=0(root) groups=0(root)
#root   Yes   UID  =  0,GID  =  0
[[email protected] ~]# id -a
uid=0(root) gid=0(root) groups=0(root)
[[email protected] ~]# id -g
0
[[email protected] ~]# id -G
0
[[email protected] ~]# id mingongge
uid=1000(mingongge) gid=1000(mingongge) groups=1000(mingongge)

Learn a Linux command every day (51): which

Learn a Linux command every day (52): where is

Learn a Linux command every day (53): who