📄 id.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>id</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_001_014_966"> </a>NAME</h4><blockquote>id - return user identity</blockquote><h4><a name = "tag_001_014_967"> </a>SYNOPSIS</h4><blockquote><pre><code>id <b>[</b><i>user</i><b>]</b>id -G<b>[</b>-n<b>] [</b><i>user</i><b>]</b>id -g<b>[</b>-nr<b>] [</b><i>user</i><b>]</b>id -u<b>[</b>-nr<b>] [</b><i>user</i><b>]</b></code></pre></blockquote><h4><a name = "tag_001_014_968"> </a>DESCRIPTION</h4><blockquote>If no<i>user</i>operand is provided, the<i>id</i>utility will write the user and group IDsand the corresponding user and group names of theinvoking process to standard output.If the effective and real IDs do not match, both will be written.If multiple groups are supported by the underlying system(see the description of{NGROUPS_MAX}in the <b>XSH</b> specification), the supplementary group affiliations of the invoking processalso will be written.<p>If a<i>user</i>operand is provided and the process has the appropriate privileges, theuser and group IDs of the selected user will be written.In this case, effective IDswill be assumed to be identical to real IDs.If the selected user has more than one allowable group membershiplisted in the group database,these will be written in the same manner as thesupplementary groups described in the preceding paragraph.</blockquote><h4><a name = "tag_001_014_969"> </a>OPTIONS</h4><blockquote>The<i>id</i>utility supports the <b>XBD</b> specification, <a href="../xbd/utilconv.html#usg"><b>Utility Syntax Guidelines</b> </a> .<p>The following options are supported:<dl compact><dt><b>-G</b><dd>Output all different group IDs (effective, real and supplementary)only, using the format%u\n.If there is morethan one distinct group affiliation, output each suchaffiliation, using the format %u,before thenewline characteris output.<dt><b>-g</b><dd>Output only the effective group ID, using the format%u\n.<dt><b>-n</b><dd>Output the name in the format%sinstead of the numeric ID using the format%u.<dt><b>-r</b><dd>Output the real ID instead of the effective ID.<dt><b>-u</b><dd>Output only the effective user ID, using the format%u\n.</dl></blockquote><h4><a name = "tag_001_014_970"> </a>OPERANDS</h4><blockquote>The following operand is supported:<dl compact><dt><i>user</i><dd>The login name for which information is to be written.</dl></blockquote><h4><a name = "tag_001_014_971"> </a>STDIN</h4><blockquote>Not used.</blockquote><h4><a name = "tag_001_014_972"> </a>INPUT FILES</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_973"> </a>ENVIRONMENT VARIABLES</h4><blockquote>The following environment variables affect the execution of<i>id</i>:<dl compact><dt><i>LANG</i><dd>Provide a default value for the internationalisation variablesthat are unset or null.If<i>LANG</i>is unset or null, the corresponding value from theimplementation-dependent default locale will be used.If any of the internationalisation variables contains an invalid setting, theutility will behave as if none of the variables had been defined.<dt><i>LC_ALL</i><dd>If set to a non-empty string value,override the values of all the other internationalisation variables.<dt><i>LC_CTYPE</i><dd>Determine thelocale for the interpretation of sequences of bytes of text data ascharacters (for example, single- as opposed to multi-byte charactersin arguments).<dt><i>LC_MESSAGES</i><dd>Determine the locale that should be used to affectthe format and contents of diagnosticmessages written to standard errorand informative messages written to standard output.<dt><i>NLSPATH</i><dd>Determine the location of message cataloguesfor the processing of<i>LC_MESSAGES .</i></dl></blockquote><h4><a name = "tag_001_014_974"> </a>ASYNCHRONOUS EVENTS</h4><blockquote>Default.</blockquote><h4><a name = "tag_001_014_975"> </a>STDOUT</h4><blockquote>The following formats will be used when the LC_MESSAGES locale categoryspecifies the POSIX locale.In other locales, the strings<b>uid,</b><b>gid,</b><b>euid,</b><b>egid</b>and<b>groups</b>may be replaced with more appropriate stringscorresponding to the locale.<p><code><pre><tt>"uid=%u(%s) gid=%u(%s)\n"</tt>, <<i>real user ID</i>>,<<i>user-name</i>>,<<i>real group ID</i>>,<<i>group-name</i>></pre></code><p>If the effective and real user IDs do not match,the following will be insertedimmediately before the\ncharacter in the previous format:<pre><code>" euid=%u(%s)"</code></pre>with the following arguments added at the end of the argument list:<p><code><pre><<i>effective user ID</i>>,<<i>effective user-name</i>></pre></code><p>If the effective and real group IDs do not match,the following will be inserted directly before the\ncharacter in the format string(and after any additionresulting from the effective and real user IDs not matching):<pre><code>" egid=%u(%s)"</code></pre>with the following arguments added at the end of the argument list:<p><code><pre><<i>effective group-ID</i>>,<<i>effective group name</i>></pre></code><p>If the process has supplementary group affiliationsor the selected user is allowed to belong to multiple groups,the first will beadded directly before thenewlinecharacter in the format string:<pre><code>" groups=%u(%s)"</code></pre>with the following arguments added at the end of the argument list:<p><code><<i>supplementary group ID</i>>,<<i>supplementary group name</i>></code>and the necessary number of the following added after that for anyremaining supplementary group IDs:<p><code>,%u(%s)</code>and the necessary number of the following arguments added at the end ofthe argument list:<p><code><<i>supplementary group ID</i>>,<<i>supplementary group name</i>></code><p>If any of the user ID, group ID, effective user ID, effective group IDor supplementary/multiplegroup IDs cannot be mapped by the system into printableuser or group names, the corresponding(<b>%s</b>)and name argument will beomitted from the corresponding format string.<p>When any of the options are specified,the output format will be as described in the OPTIONS section.</blockquote><h4><a name = "tag_001_014_976"> </a>STDERR</h4><blockquote>Used only for diagnostic messages.</blockquote><h4><a name = "tag_001_014_977"> </a>OUTPUT FILES</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_978"> </a>EXTENDED DESCRIPTION</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_979"> </a>EXIT STATUS</h4><blockquote>The following exit values are returned:<dl compact><dt>0<dd>Successful completion.<dt>>0<dd>An error occurred.</dl></blockquote><h4><a name = "tag_001_014_980"> </a>CONSEQUENCES OF ERRORS</h4><blockquote>Default.</blockquote><h4><a name = "tag_001_014_981"> </a>APPLICATION USAGE</h4><blockquote>Output produced by the<b>-G</b>option and by the default case couldpotentially produce very long lines on systems that support large numbersof supplementary groups.(On systems with user and group IDs that are32-bit integers and with group names with a maximum of 8 bytes per name,93 supplementary groups plus distinct effective and real group and userIDs could theoretically overflow the 2048-byte{LINE_MAX}text file line limit on the default output case.It would take about 186 supplementarygroups to overflow the 2048-byte barrier using<i>id</i><b>-G</b>).This is notexpected to be a problem in practice, but in cases where it is a concern,applications should consider using<i><a href="fold.html">fold</a></i><b>-s</b>before postprocessing the output of<i>id</i>.</blockquote><h4><a name = "tag_001_014_982"> </a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_983"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_984"> </a>SEE ALSO</h4><blockquote><i><a href="fold.html">fold</a></i>,<i><a href="logname.html">logname</a></i>,<i><a href="who.html">who</a></i>,the <b>XSH</b> specification description of<i><a href="../xsh/getgid.html">getgid()</a></i>,<i><a href="../xsh/getgroups.html">getgroups()</a></i>,<i><a href="../xsh/getuid.html">getuid()</a></i>.</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -