Un outil pour savoir si une commande est posix - retour accueil
git clone git://bebou.netlib.re/isposix
Log | Files | Refs | README |
id.html (14186B)
1 <!-- Copyright 2001-2024 IEEE and The Open Group, All Rights Reserved --> 2 <!DOCTYPE HTML> 3 <html lang="en"> 4 <head> 5 <meta name="generator" content="HTML Tidy for HTML5 for Linux version 5.8.0"> 6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 7 <link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group rhtm tool v1.2.4 --> 8 <!-- Copyright (c) 2001-2024 The Open Group, All Rights Reserved --> 9 <title>id</title> 10 </head> 11 <body bgcolor="white"> 12 <div class="NAVHEADER"> 13 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0"> 14 <tr class="nav"> 15 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/iconv.html" accesskey="P"><<< 16 Previous</a></td> 17 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td> 18 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/ipcrm.html" accesskey="N">Next 19 >>></a></td> 20 </tr> 21 </table> 22 <hr align="left" width="100%"></div> 23 <script language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> 24 <center><font size="2">The Open Group Base Specifications Issue 8<br> 25 IEEE Std 1003.1-2024<br> 26 Copyright © 2001-2024 The IEEE and The Open Group</font></center> 27 <hr size="2" noshade> 28 <a name="top" id="top"></a> <a name="id" id="id"></a> <a name="tag_20_59" id="tag_20_59"></a><!-- id --> 29 <h4 class="mansect"><a name="tag_20_59_01" id="tag_20_59_01"></a>NAME</h4> 30 <blockquote>id — return user identity</blockquote> 31 <h4 class="mansect"><a name="tag_20_59_02" id="tag_20_59_02"></a>SYNOPSIS</h4> 32 <blockquote class="synopsis"> 33 <p><code><tt>id</tt> <b>[</b><i>user</i><b>]</b> <tt><br> 34 <br> 35 id -G</tt> <b>[</b><tt>-n</tt><b>] [</b><i>user</i><b>]</b> <tt><br> 36 <br> 37 id -g</tt> <b>[</b><tt>-nr</tt><b>] [</b><i>user</i><b>]</b> <tt><br> 38 <br> 39 id -u</tt> <b>[</b><tt>-nr</tt><b>] [</b><i>user</i><b>]</b> <tt><br></tt></code></p> 40 </blockquote> 41 <h4 class="mansect"><a name="tag_20_59_03" id="tag_20_59_03"></a>DESCRIPTION</h4> 42 <blockquote> 43 <p>If no <i>user</i> operand is provided, the <i>id</i> utility shall write the user and group IDs and the corresponding user and 44 group names of the invoking process to standard output. If the effective and real IDs do not match, both shall be written. If 45 multiple groups are supported by the underlying system (see the description of {NGROUPS_MAX} in the System Interfaces volume of 46 POSIX.1-2024), the supplementary group affiliations of the invoking process shall also be written.</p> 47 <p>If a <i>user</i> operand is provided and the process has appropriate privileges, the user and group IDs of the selected user 48 shall be written. In this case, effective IDs shall be assumed to be identical to real IDs. If the selected user has more than one 49 allowable group membership listed in the group database, these shall be written in the same manner as the supplementary groups 50 described in the preceding paragraph.</p> 51 </blockquote> 52 <h4 class="mansect"><a name="tag_20_59_04" id="tag_20_59_04"></a>OPTIONS</h4> 53 <blockquote> 54 <p>The <i>id</i> utility shall conform to XBD <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax 55 Guidelines</i></a> .</p> 56 <p>The following options shall be supported:</p> 57 <dl compact> 58 <dd></dd> 59 <dt><b>-G</b></dt> 60 <dd>Output all different group IDs (effective, real, and supplementary) only, using the format <tt>"%u\n"</tt>. If there is more 61 than one distinct group affiliation, output each such affiliation, using the format <tt>" %u"</tt>, before the <newline> 62 is output.</dd> 63 <dt><b>-g</b></dt> 64 <dd>Output only the effective group ID, using the format <tt>"%u\n"</tt>.</dd> 65 <dt><b>-n</b></dt> 66 <dd>Output the name in the format <tt>"%s"</tt> instead of the numeric ID using the format <tt>"%u"</tt>.</dd> 67 <dt><b>-r</b></dt> 68 <dd>Output the real ID instead of the effective ID.</dd> 69 <dt><b>-u</b></dt> 70 <dd>Output only the effective user ID, using the format <tt>"%u\n"</tt>.</dd> 71 </dl> 72 </blockquote> 73 <h4 class="mansect"><a name="tag_20_59_05" id="tag_20_59_05"></a>OPERANDS</h4> 74 <blockquote> 75 <p>The following operand shall be supported:</p> 76 <dl compact> 77 <dd></dd> 78 <dt><i>user</i></dt> 79 <dd>The login name for which information is to be written.</dd> 80 </dl> 81 </blockquote> 82 <h4 class="mansect"><a name="tag_20_59_06" id="tag_20_59_06"></a>STDIN</h4> 83 <blockquote> 84 <p>Not used.</p> 85 </blockquote> 86 <h4 class="mansect"><a name="tag_20_59_07" id="tag_20_59_07"></a>INPUT FILES</h4> 87 <blockquote> 88 <p>None.</p> 89 </blockquote> 90 <h4 class="mansect"><a name="tag_20_59_08" id="tag_20_59_08"></a>ENVIRONMENT VARIABLES</h4> 91 <blockquote> 92 <p>The following environment variables shall affect the execution of <i>id</i>:</p> 93 <dl compact> 94 <dd></dd> 95 <dt><i>LANG</i></dt> 96 <dd>Provide a default value for the internationalization variables that are unset or null. (See XBD <a href= 97 "../basedefs/V1_chap08.html#tag_08_02"><i>8.2 Internationalization Variables</i></a> for the precedence of internationalization 98 variables used to determine the values of locale categories.)</dd> 99 <dt><i>LC_ALL</i></dt> 100 <dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd> 101 <dt><i>LC_CTYPE</i></dt> 102 <dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as 103 opposed to multi-byte characters in arguments).</dd> 104 <dt><i>LC_MESSAGES</i></dt> 105 <dd><br> 106 Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error and 107 informative messages written to standard output.</dd> 108 <dt><i>NLSPATH</i></dt> 109 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> 110 Determine the location of messages objects and message catalogs. <img src="../images/opt-end.gif" alt="[Option End]" border= 111 "0"></dd> 112 </dl> 113 </blockquote> 114 <h4 class="mansect"><a name="tag_20_59_09" id="tag_20_59_09"></a>ASYNCHRONOUS EVENTS</h4> 115 <blockquote> 116 <p>Default.</p> 117 </blockquote> 118 <h4 class="mansect"><a name="tag_20_59_10" id="tag_20_59_10"></a>STDOUT</h4> 119 <blockquote> 120 <p>The following formats shall be used when the <i>LC_MESSAGES</i> locale category specifies the POSIX locale. In other locales, 121 the strings <i>uid</i>, <i>gid</i>, <i>euid</i>, <i>egid</i>, and <i>groups</i> may be replaced with more appropriate strings 122 corresponding to the locale.</p> 123 <pre> 124 <tt>"uid=%u(%s) gid=%u(%s)\n", <</tt><i>real user ID</i><tt>>, <</tt><i>user-name</i><tt>>, 125 <</tt><i>real group ID</i><tt>>, <</tt><i>group-name</i><tt>> 126 </tt></pre> 127 <p>If the effective and real user IDs do not match, the following shall be inserted immediately before the <tt>'\n'</tt> character 128 in the previous format:</p> 129 <pre> 130 <tt>" euid=%u(%s)" 131 </tt></pre> 132 <p>with the following arguments added at the end of the argument list:</p> 133 <pre> 134 <tt><</tt><i>effective user ID</i><tt>>, <</tt><i>effective user-name</i><tt>> 135 </tt></pre> 136 <p>If the effective and real group IDs do not match, the following shall be inserted directly before the <tt>'\n'</tt> character in 137 the format string (and after any addition resulting from the effective and real user IDs not matching):</p> 138 <pre> 139 <tt>" egid=%u(%s)" 140 </tt></pre> 141 <p>with the following arguments added at the end of the argument list:</p> 142 <pre> 143 <tt><</tt><i>effective group-ID</i><tt>>, <</tt><i>effective group name</i><tt>> 144 </tt></pre> 145 <p>If the process has supplementary group affiliations or the selected user is allowed to belong to multiple groups, the first 146 shall be added directly before the <newline> in the format string:</p> 147 <pre> 148 <tt>" groups=%u(%s)" 149 </tt></pre> 150 <p>with the following arguments added at the end of the argument list:</p> 151 <pre> 152 <tt><</tt><i>supplementary group ID</i><tt>>, <</tt><i>supplementary group name</i><tt>> 153 </tt></pre> 154 <p>and the necessary number of the following added after that for any remaining supplementary group IDs:</p> 155 <pre> 156 <tt>",%u(%s)" 157 </tt></pre> 158 <p>and the necessary number of the following arguments added at the end of the argument list:</p> 159 <pre> 160 <tt><</tt><i>supplementary group ID</i><tt>>, <</tt><i>supplementary group name</i><tt>> 161 </tt></pre> 162 <p>If any of the user ID, group ID, effective user ID, effective group ID, or supplementary/multiple group IDs cannot be mapped by 163 the system into printable user or group names, the corresponding <tt>"(%s)"</tt> and <i>name</i> argument shall be omitted from the 164 corresponding format string.</p> 165 <p>When any of the options are specified, the output format shall be as described in the OPTIONS section.</p> 166 </blockquote> 167 <h4 class="mansect"><a name="tag_20_59_11" id="tag_20_59_11"></a>STDERR</h4> 168 <blockquote> 169 <p>The standard error shall be used only for diagnostic messages.</p> 170 </blockquote> 171 <h4 class="mansect"><a name="tag_20_59_12" id="tag_20_59_12"></a>OUTPUT FILES</h4> 172 <blockquote> 173 <p>None.</p> 174 </blockquote> 175 <h4 class="mansect"><a name="tag_20_59_13" id="tag_20_59_13"></a>EXTENDED DESCRIPTION</h4> 176 <blockquote> 177 <p>None.</p> 178 </blockquote> 179 <h4 class="mansect"><a name="tag_20_59_14" id="tag_20_59_14"></a>EXIT STATUS</h4> 180 <blockquote> 181 <p>The following exit values shall be returned:</p> 182 <dl compact> 183 <dd></dd> 184 <dt> 0</dt> 185 <dd>Successful completion.</dd> 186 <dt>>0</dt> 187 <dd>An error occurred.</dd> 188 </dl> 189 </blockquote> 190 <h4 class="mansect"><a name="tag_20_59_15" id="tag_20_59_15"></a>CONSEQUENCES OF ERRORS</h4> 191 <blockquote> 192 <p>Default.</p> 193 </blockquote> 194 <hr> 195 <div class="box"><em>The following sections are informative.</em></div> 196 <h4 class="mansect"><a name="tag_20_59_16" id="tag_20_59_16"></a>APPLICATION USAGE</h4> 197 <blockquote> 198 <p>Output produced by the <b>-G</b> option and by the default case could potentially produce very long lines on systems that 199 support large numbers of supplementary groups. (On systems with user and group IDs that are 32-bit integers and with group names 200 with a maximum of 8 bytes per name, 93 supplementary groups plus distinct effective and real group and user IDs could theoretically 201 overflow the 2048-byte {LINE_MAX} text file line limit on the default output case. It would take about 186 supplementary groups to 202 overflow the 2048-byte barrier using <i>id</i> <b>-G</b>). This is not expected to be a problem in practice, but in cases where it 203 is a concern, applications should consider using <a href="../utilities/fold.html"><i>fold</i></a> <b>-s</b> before post-processing 204 the output of <i>id</i>.</p> 205 </blockquote> 206 <h4 class="mansect"><a name="tag_20_59_17" id="tag_20_59_17"></a>EXAMPLES</h4> 207 <blockquote> 208 <p>None.</p> 209 </blockquote> 210 <h4 class="mansect"><a name="tag_20_59_18" id="tag_20_59_18"></a>RATIONALE</h4> 211 <blockquote> 212 <p>The functionality provided by the 4 BSD <i>groups</i> utility can be simulated using:</p> 213 <pre> 214 <tt>id -Gn [ user ] 215 </tt></pre> 216 <p>The 4 BSD command <i>groups</i> was considered, but it was not included because it did not provide the functionality of the 217 <i>id</i> utility of the SVID. Also, it was thought that it would be easier to modify <i>id</i> to provide the additional 218 functionality necessary to systems with multiple groups than to invent another command.</p> 219 <p>The options <b>-u</b>, <b>-g</b>, <b>-n</b>, and <b>-r</b> were added to ease the use of <i>id</i> with shell commands 220 substitution. Without these options it is necessary to use some preprocessor such as <a href="../utilities/sed.html"><i>sed</i></a> 221 to select the desired piece of information. Since output such as that produced by:</p> 222 <pre> 223 <tt>id -u -n 224 </tt></pre> 225 <p>is frequently wanted, it seemed desirable to add the options.</p> 226 </blockquote> 227 <h4 class="mansect"><a name="tag_20_59_19" id="tag_20_59_19"></a>FUTURE DIRECTIONS</h4> 228 <blockquote> 229 <p>None.</p> 230 </blockquote> 231 <h4 class="mansect"><a name="tag_20_59_20" id="tag_20_59_20"></a>SEE ALSO</h4> 232 <blockquote> 233 <p><a href="../utilities/fold.html#"><i>fold</i></a> , <a href="../utilities/logname.html#"><i>logname</i></a> , <a href= 234 "../utilities/who.html#"><i>who</i></a></p> 235 <p>XBD <a href="../basedefs/V1_chap08.html#tag_08"><i>8. Environment Variables</i></a> , <a href= 236 "../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax Guidelines</i></a></p> 237 <p>XSH <a href="../functions/getgid.html#"><i>getgid</i></a> , <a href="../functions/getgroups.html#"><i>getgroups</i></a> , 238 <a href="../functions/getuid.html#"><i>getuid</i></a></p> 239 </blockquote> 240 <h4 class="mansect"><a name="tag_20_59_21" id="tag_20_59_21"></a>CHANGE HISTORY</h4> 241 <blockquote> 242 <p>First released in Issue 2.</p> 243 </blockquote> 244 <h4 class="mansect"><a name="tag_20_59_22" id="tag_20_59_22"></a>Issue 7</h4> 245 <blockquote> 246 <p>SD5-XCU-ERN-97 is applied, updating the SYNOPSIS.</p> 247 </blockquote> 248 <h4 class="mansect"><a name="tag_20_59_23" id="tag_20_59_23"></a>Issue 8</h4> 249 <blockquote> 250 <p>Austin Group Defect 1122 is applied, changing the description of <i>NLSPATH .</i></p> 251 </blockquote> 252 <div class="box"><em>End of informative text.</em></div> 253 <hr> 254 <p> </p> 255 <a href="#top"><span class="topOfPage">return to top of page</span></a><br> 256 <hr size="2" noshade> 257 <center><font size="2">UNIX® is a registered Trademark of The Open Group.<br> 258 POSIX™ is a Trademark of The IEEE.<br> 259 Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved<br> 260 [ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href= 261 "../functions/contents.html">XSH</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../xrat/contents.html">XRAT</a> 262 ]</font></center> 263 <hr size="2" noshade> 264 <div class="NAVHEADER"> 265 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0"> 266 <tr class="nav"> 267 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/iconv.html" accesskey="P"><<< 268 Previous</a></td> 269 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td> 270 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/ipcrm.html" accesskey="N">Next 271 >>></a></td> 272 </tr> 273 </table> 274 <hr align="left" width="100%"></div> 275 </body> 276 </html>