'\" te .\" Portions Copyright (c) 2002, 2012, Oracle and/or its affiliates.All rights reserved. .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation.Original documentation from The Open Group can be obtained online at http://www.opengroup.org/bookstore/. .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation.In the following statement, the phrase"this text" refers to portions of the system documentation.Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group.In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard,the original IEEE and The Open Group Standard is the referee document.The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.This notice shall appear on any product containing this material. .TH id 1M "2006 年 11 月 28 日" "SunOS 5.11" "系统管理命令" .SH 名称 id \- 返回用户标识 .SH 用法概要 .LP .nf \fB/usr/bin/id\fR [\fB-p\fR] [\fIuser\fR] .fi .LP .nf \fB/usr/bin/id\fR \fB-a\fR [\fB-p\fR] [\fIuser\fR] .fi .LP .nf \fB/usr/bin/id\fR \fB-G\fR [\fB-n\fR] [\fIuser\fR] .fi .LP .nf \fB/usr/bin/id\fR \fB-g\fR [\fB-nr\fR] [\fIuser\fR] .fi .LP .nf \fB/usr/bin/id\fR \fB-u\fR [\fB-nr\fR] [\fIuser\fR] .fi .LP .nf \fB/usr/xpg4/bin/id\fR [\fB-p\fR] [\fIuser\fR] .fi .LP .nf \fB/usr/xpg4/bin/id\fR \fB-a\fR [\fB-p\fR] [\fIuser\fR] .fi .LP .nf \fB/usr/xpg4/bin/id\fR \fB-G\fR [\fB-n\fR] [\fIuser\fR] .fi .LP .nf \fB/usr/xpg4/bin/id\fR \fB-g\fR [\fB-nr\fR] [\fIuser\fR] .fi .LP .nf \fB/usr/xpg4/bin/id\fR \fB-u\fR [\fB-nr\fR] [\fIuser\fR] .fi .SH 描述 .sp .LP 如果未提供任何 \fIuser\fR 操作数,则 \fBid\fR 实用程序会将用户和组 \fBID\fR 以及调用进程的相应用户和组名称写入标准输出。如果有效和实际 \fBID\fR 不匹配,则会同时写入这两项。如果底层系统支持多个组,则 \fB/usr/xpg4/bin/id\fR 还会写入调用进程的补充组联合提供者。 .sp .LP 如果提供了 \fIuser\fR 操作数,并且进程具有适当的特权,则会写入选定用户的用户和组 \fBID\fR。在这种情况下,系统会假定有效 \fBID\fR 与实际 \fBID\fR 相同。如果选定用户在组数据库中列出了多个允许的组成员关系,则 \fB/usr/xpg4/bin/id\fR 会按照上一段所述的写入补充组的方式写入这些组成员关系。 .SS "格式" .sp .LP 当 \fBLC_MESSAGES\fR 语言环境类别指定 "C" 语言环境时,会使用以下格式。在其他语言环境中,字符串 \fBuid\fR、\fBgid\fR、\fBeuid\fR、\fBegid\fR 和 \fBgroups\fR 可能会替换为最适用于相应语言环境的字符串。 .sp .in +2 .nf "uid=%u(%s) gid=%u(%s)\en" <\fIreal user ID\fR>, <\fIuser-name\fR>, <\fIreal group ID\fR>, <\fIgroup-name\fR> .fi .in -2 .sp .sp .LP 如果有效和实际用户 \fBID\fR 不匹配,则会在上述格式中的 \fB\n\fR 字符前面插入以下内容: .sp .in +2 .nf " euid=%u(%s)" .fi .in -2 .sp .sp .LP 并在参数列表末尾添加以下参数: .sp .in +2 .nf <\fIeffective user ID\fR>, <\fIeffective user-name\fR> .fi .in -2 .sp .sp .LP 如果有效和实际组 \fBID\fR 不匹配,则会在格式字符串中的 \fB\n\fR 字符前面(以及因有效和实际用户 \fBID\fR 不匹配而添加的任何内容后面)插入以下内容: .sp .in +2 .nf " egid=%u(%s)" .fi .in -2 .sp .sp .LP 并在参数列表末尾添加以下参数: .sp .in +2 .nf <\fIeffectivegroup-ID\fR>, <\fIeffectivegroupname\fR> .fi .in -2 .sp .sp .LP 如果进程具有补充组联合提供者,或者允许选定用户属于多个组,则会在格式字符串中的\fB换行\fR符前面添加第一个组: .sp .in +2 .nf " groups=%u(%s)" .fi .in -2 .sp .sp .LP 并在参数列表末尾添加以下参数: .sp .in +2 .nf <\fIsupplementary group ID\fR>, <\fIsupplementary group name\fR> .fi .in -2 .sp .sp .LP 而对于任何其余补充组 \fBID\fR,会在此内容后面添加所需数量的以下内容: .sp .in +2 .nf ",%u(%s)" .fi .in -2 .sp .sp .LP 并在参数列表末尾添加所需数量的以下参数: .sp .in +2 .nf <\fIsupplementary group ID\fR>, <\fIsupplementary group name\fR> .fi .in -2 .sp .sp .LP 如果系统无法将用户 \fBID\fR、组 \fBID\fR、有效用户 \fBID\fR、有效组 \fBID\fR 或补充组/多个组 \fBID\fR 中的任一项映射到可输出的用户名或组名称,则相应的格式字符串就会省略相应的 (\fB%s\fR) 和名称参数。 .sp .LP 如果指定了任何选项,则输出格式如“选项”下所述。 .SH 选项 .sp .LP \fB/usr/bin/id\fR 和 \fB/usr/xpg4/bin/id\fR 支持以下选项。如果与 \fB-G\fR、\fB-g\fR 或 \fB-u\fR 选项中的任一项一起指定,则 \fB-p\fR 和 \fB-a\fR 选项无效。 .sp .ne 2 .mk .na \fB\fB-p\fR\fR .ad .RS 6n .rt 此外,还会报告调用进程的当前项目成员关系。项目采用以下格式报告: .sp .in +2 .nf "projid=%u(%s)" .fi .in -2 .sp 此内容会插入到\fB\fR“格式”部分所述的缺省格式中的 \fB\n\fR 字符之前。参数 .sp .in +2 .nf <\fIproject ID\fR>,<\fIproject name\fR> .fi .in -2 .sp 会附加到参数列表的末尾。如果系统无法将项目 \fBID\fR 映射到可输出的项目名称,则相应的格式字符串会省略相应的 \fB(%s)\fR 和名称参数。 .RE .sp .ne 2 .mk .na \fB\fB-a\fR\fR .ad .RS 6n .rt 报告用户名、用户 \fBID\fR 和用户所属的所有组。 .RE .sp .ne 2 .mk .na \fB\fB-G\fR\fR .ad .RS 6n .rt 仅输出所有不同的组 \fBID\fR(有效、实际和补充),采用 \fB"%u\n"\fR 格式。如果有多个不同的组联合提供者,则使用格式 \fB" %u"\fR 输出每个联合提供者,然后再输出\fB换行\fR符。 .RE .sp .ne 2 .mk .na \fB\fB-g\fR\fR .ad .RS 6n .rt 仅输出有效组 \fBID\fR,采用 \fB"%u\n"\fR 格式。 .RE .sp .ne 2 .mk .na \fB\fB-n\fR\fR .ad .RS 6n .rt 使用格式 \fB"%s"\fR 输出名称,而不是使用格式 \fB"%u"\fR 输出数字 \fBID\fR。 .RE .sp .ne 2 .mk .na \fB\fB-r\fR\fR .ad .RS 6n .rt 输出实际 \fBID\fR 而不输出有效 \fBID\fR。 .RE .sp .ne 2 .mk .na \fB\fB-u\fR\fR .ad .RS 6n .rt 仅输出有效用户 \fBID\fR,采用 \fB"%u\n"\fR 格式。 .RE .SH 操作数 .sp .LP 支持下列操作数: .sp .ne 2 .mk .na \fB\fIuser\fR\fR .ad .RS 8n .rt 要写入信息的用户(登录)名。 .RE .SH 环境变量 .sp .LP 有关影响 \fBid\fR 执行的以下环境变量的说明,请参见 \fBenviron\fR(5):\fBLANG\fR、\fBLC_ALL\fR、\fBLC_CTYPE\fR、\fBLC_MESSAGES\fR 和 \fBNLSPATH\fR。 .SH 退出状态 .sp .LP 将返回以下退出值: .sp .ne 2 .mk .na \fB\fB0\fR\fR .ad .RS 6n .rt 成功完成。 .RE .sp .ne 2 .mk .na \fB\fB>0\fR\fR .ad .RS 6n .rt 出现错误。 .RE .SH 属性 .sp .LP 有关下列属性的说明,请参见 \fBattributes\fR(5): .SS "/usr/bin/id" .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . 属性类型属性值 _ 可用性T{ system/core-os、system/library/processor T} _ 接口稳定性Committed(已确定) .TE .SS "/usr/xpg4/bin/id" .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . 属性类型属性值 _ 可用性system/xopen/xcu4 _ 接口稳定性Standard(标准) .TE .SH 另请参见 .sp .LP \fBfold\fR(1)、\fBlogname\fR(1)、\fBwho\fR(1)、\fBgetgid\fR(2)、\fBgetgroups\fR(2)、\fBgetprojid\fR(2)、\fBgetuid\fR(2)、\fBattributes\fR(5)、\fBenviron\fR(5)、\fBstandards\fR(5) .SH 附注 .sp .LP \fB-G\fR 选项生成的输出以及缺省情况下生成的输出可能会在支持大量补充组的系统上生成很长的行。