欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

id 命令 有大用 有大大用 有大大大用

id命令的常用选项 


# id -Gn    [ username ]          #显示与组有关的信息  G就是group的意思   [ username ] 省略表示当前用户    

# id -g  [ username ]       #显示与组id    g就是group的意思 这是主组吧

# id -G  [ username ]        #这是用户的所有组

# id -F         #显示登录帐号,Display the full name of the user.

# id -P         #显示密码文件中(mac中好像 不是 /etc/passwd ) 相关的信息  ,,,,Display the id as a password file entry.将id显示为密码文件条目。P就是 password的意思 

# id -u [ username ]        #显示id,,省略用户名就是当前用户

# id -un         #显示 用户的名称 u就是user,,,,,n就是name 相当于 whoami

# id -P         #显示密码文件中(mac中好像 不是 /etc/passwd ) 相关的信息  ,,,,Display the id as a password file entry.将id显示为密码文件条目。 

# id -P         #显示密码文件中(mac中好像 不是 /etc/passwd ) 相关的信息  ,,,,Display the id as a password file entry.将id显示为密码文件条目。 

# id -P         #显示密码文件中(mac中好像 不是 /etc/passwd ) 相关的信息  ,,,,Display the id as a password file entry.将id显示为密码文件条目。 


macos id 命令的常用选项

在 macOS 中,id 命令用于显示用户的用户 ID、组 ID 和所属的组。以下是 id 命令的一些常用选项:

  1. -nu:显示用户的用户 ID 和组 ID。

  2. -ng:显示用户的组 ID。

  3. -g:显示用户所属的主要组 ID。

  4. -G:显示用户所属的所有组 ID。

  5. -r:显示用户的角色。

  6. -a:显示用户所属的所有组名称。

  7. -gGnu:显示用户的用户 ID、组 ID、所属的主要组 ID 和附加组 ID。

  8. -nr:显示用户的用户名、用户 ID 和角色。

  9. -ngr:显示用户的用户名和组 ID。

这些选项可以根据需要进行组合使用,以获取所需的用户信息。例如,使用 id -nu 命令可以显示当前用户的用户 ID 和组 ID。


id 编号 

User identity - display the user and group names (and IDs)用户标识 - 显示用户名和组名(以及 ID)
The groups utility has been obsoleted by id, and is equivalent to `id -Gn [user]'groups 实用程序已被 id 废弃,等同于 'id -Gn [user]'

            Syntax
      id [user]
      id -A
      id -G [-n] [user]
      id -M
      id -P [user]
      id -g [-nr] [user]
      id -p [user]
      id -u [-nr] [user]

Options
   -A     Display the process audit user ID and other process audit properties, which requires privilege.  显示流程审核用户ID和其他流程审核属性,这需要权限。

   -G     Display the different group IDs (effective, real and supplementary)
         as white-space separated numbers, in no particular order.显示不同的组ID(有效、真实和补充)

作为空白分隔的数字。 -M Display the MAC label of the current process.显示当前进程的MAC标签。 -P Display the id as a password file entry.将id显示为密码文件条目。 -g Display the effective group ID as a number.将有效组ID显示为数字 -n Display the name of the user or group ID for the -G, -g and -u options instead of the number. If any of the ID numbers cannot be mapped into names, the number will be displayed as usual.
显示-G、-G和-u的用户或组ID的名称

选项而不是数字。如果任何身份证号码不能

被映射到名称中,数字将照常显示。 -p Make the output human-readable. If the user name returned by getlogin(2) is different from the login name referenced by the user ID, the name returned by getlogin(2) is displayed, preceded by the keyword `login'. The user ID as a name is displayed, preceded by the keyword `uid'. If the effective user ID is different from the real user ID, the real user ID is displayed as a name, preceded by the keyword `euid'. If the effective group ID is different from the real group ID, the real group ID is displayed as a name, preceded by the keyword `rgid'. The list of groups to which the user belongs is then displayed as names, preceded by the keyword `groups'. Each display is on a separate line.
使输出具有可读性。如果返回的用户名

getlogin(2)与

用户ID,显示getlogin(2)返回的名称,前面

通过关键字“login”。显示作为名称的用户ID,

前面是关键字“uid”。如果有效的用户ID为

与真实用户ID不同,真实用户ID显示为

名称,前面加关键字“euid”。如果有效组

ID与真实组ID不同,显示真实组ID

作为名称,前面加上关键字“rgid”。的列表

然后,用户所属的组显示为名称,前面是

通过关键字“groups”。每个显示器都在一条单独的线上。 -r Display the real ID for the -g and -u options instead of the effective ID.显示-g和-u选项的真实ID,而不是有效ID。 -u Display the effective user ID as a number. 将有效的用户ID显示为数字。

NAME
id – return user identity

SYNOPSIS
id [user]
id -A
id -F [user]
id -G [-n] [user]
id -P [user]
id -g [-nr] [user]
id -p [user]
id -u [-nr] [user]

DESCRIPTION
The id utility displays the user and group names and numeric IDs, of the calling process, to the standard output. If the real and effective IDs are different, both are displayed, otherwise only the real ID is
displayed.

If a user (login name or user ID) is specified, the user and group IDs of that user are displayed. In this case, the real and effective IDs are assumed to be the same.

The options are as follows:

-A Display the process audit user ID and other process audit properties, which requires privilege.

-F Display the full name of the user.

-G Display the different group IDs (effective, real and supplementary) as white-space separated numbers, in no particular order.

-P Display the id as a password file entry.

-a Ignored for compatibility with other id implementations.

-g Display the effective group ID as a number.

-n Display the name of the user or group ID for the -G, -g and -u options instead of the number. If any of the ID numbers cannot be mapped into names, the number will be displayed as usual.

-p Make the output human-readable. If the user name returned by getlogin(2) is different from the login name referenced by the user ID, the name returned by getlogin(2) is displayed, preceded by the
keyword “login”. The user ID as a name is displayed, preceded by the keyword “uid”. If the effective user ID is different from the real user ID, the real user ID is displayed as a name, preceded by the
keyword “euid”. If the effective group ID is different from the real group ID, the real group ID is displayed as a name, preceded by the keyword “rgid”. The list of groups to which the user belongs is
then displayed as names, preceded by the keyword “groups”. Each display is on a separate line.

-r Display the real ID for the -g and -u options instead of the effective ID.

-u Display the effective user ID as a number.

EXIT STATUS

Displays the user and group names and numeric IDs, of the calling process, to the standard output.将调用进程的用户名和组名以及数字 ID 显示到标准输出中。

If the real and effective IDs are different, both are displayed, otherwise only the real ID is displayed.如果真实ID和有效ID不同,则显示两者,否则仅显示真实ID。

The id utility exits 0 on success, and >0 if an error occurs.id 实用程序在成功时退出 0,如果发生错误,则退出 >0。

If a user (login name or user ID) is specified, the user and group IDs of that user are displayed. In this case, the real and effective IDs are assumed to be the same.如果指定了用户(登录名或用户 ID),则显示该用户的用户和组 ID。在这种情况下,假定真实 ID 和有效 ID 相同。

"There is no monument dedicated to the memory of a committee" ~ Lester J. Pourciau“没有纪念碑专门纪念一个委员会”~ Lester J. Pourciau

Related macOS commands 相关 macOS 命令 

The historic groups command is equivalent to id -Gn [user]historic groups 命令等同于 id -Gn [user]
The historic whoami command is equivalent to id -un历史 whoami 命令等效于 id -un
who - Print all users currently logged in.who - 打印当前登录的所有用户。
whoami - Print real user name.whoami - 打印真实用户名。
Equivalent (Linux) bash command:who - Print all users currently logged in.等效 (Linux) bash 命令:who - 打印当前登录的所有用户。


来自   https://ss64.com/osx/id.html






普通分类: