352 lines
12 KiB
HTML
352 lines
12 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
|
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
|
<title>id</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
|
</script>
|
|
|
|
<basefont size="3"> <a name="id"></a> <a name="tag_04_67"></a><!-- id -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_04_67_01"></a>NAME</h4>
|
|
|
|
<blockquote>id - return user identity</blockquote>
|
|
|
|
<h4><a name="tag_04_67_02"></a>SYNOPSIS</h4>
|
|
|
|
<blockquote class="synopsis">
|
|
<p><code><tt>id</tt> <b>[</b><i>user</i><b>]</b><tt><br>
|
|
<br>
|
|
id -G</tt><b>[</b><tt>-n</tt><b>] [</b><i>user</i><b>]</b><tt><br>
|
|
<br>
|
|
id -g</tt><b>[</b><tt>-nr</tt><b>] [</b><i>user</i><b>]</b><tt><br>
|
|
<br>
|
|
id -u</tt><b>[</b><tt>-nr</tt><b>] [</b><i>user</i><b>]</b><tt><br>
|
|
</tt></code></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_67_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<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
|
|
group names of the invoking process to standard output. If the effective and real IDs do not match, both shall be written. If
|
|
multiple groups are supported by the underlying system (see the description of {NGROUPS_MAX} in the System Interfaces volume of
|
|
IEEE Std 1003.1-2001), the supplementary group affiliations of the invoking process shall also be written.</p>
|
|
|
|
<p>If a <i>user</i> operand is provided and the process has the appropriate privileges, the user and group IDs of the selected user
|
|
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
|
|
allowable group membership listed in the group database, these shall be written in the same manner as the supplementary groups
|
|
described in the preceding paragraph.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_67_04"></a>OPTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>id</i> utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, <a href=
|
|
"../basedefs/xbd_chap12.html#tag_12_02">Section 12.2, Utility Syntax Guidelines</a>.</p>
|
|
|
|
<p>The following options shall be supported:</p>
|
|
|
|
<dl compact>
|
|
<dt><b>-G</b></dt>
|
|
|
|
<dd>Output all different group IDs (effective, real, and supplementary) only, using the format <tt>"%u\n"</tt> . If there is more
|
|
than one distinct group affiliation, output each such affiliation, using the format <tt>" %u"</tt> , before the
|
|
<newline> is output.</dd>
|
|
|
|
<dt><b>-g</b></dt>
|
|
|
|
<dd>Output only the effective group ID, using the format <tt>"%u\n"</tt> .</dd>
|
|
|
|
<dt><b>-n</b></dt>
|
|
|
|
<dd>Output the name in the format <tt>"%s"</tt> instead of the numeric ID using the format <tt>"%u"</tt> .</dd>
|
|
|
|
<dt><b>-r</b></dt>
|
|
|
|
<dd>Output the real ID instead of the effective ID.</dd>
|
|
|
|
<dt><b>-u</b></dt>
|
|
|
|
<dd>Output only the effective user ID, using the format <tt>"%u\n"</tt> .</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_67_05"></a>OPERANDS</h4>
|
|
|
|
<blockquote>
|
|
<p>The following operand shall be supported:</p>
|
|
|
|
<dl compact>
|
|
<dt><i>user</i></dt>
|
|
|
|
<dd>The login name for which information is to be written.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_67_06"></a>STDIN</h4>
|
|
|
|
<blockquote>
|
|
<p>Not used.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_67_07"></a>INPUT FILES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_67_08"></a>ENVIRONMENT VARIABLES</h4>
|
|
|
|
<blockquote>
|
|
<p>The following environment variables shall affect the execution of <i>id</i>:</p>
|
|
|
|
<dl compact>
|
|
<dt><i>LANG</i></dt>
|
|
|
|
<dd>Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of
|
|
IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap08.html#tag_08_02">Section 8.2, Internationalization Variables</a> for
|
|
the precedence of internationalization variables used to determine the values of locale categories.)</dd>
|
|
|
|
<dt><i>LC_ALL</i></dt>
|
|
|
|
<dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
|
|
|
|
<dt><i>LC_CTYPE</i></dt>
|
|
|
|
<dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
|
|
opposed to multi-byte characters in arguments).</dd>
|
|
|
|
<dt><i>LC_MESSAGES</i></dt>
|
|
|
|
<dd>Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error and
|
|
informative messages written to standard output.</dd>
|
|
|
|
<dt><i>NLSPATH</i></dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
Determine the location of message catalogs for the processing of <i>LC_MESSAGES .</i> <img src="../images/opt-end.gif" alt=
|
|
"[Option End]" border="0"></dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_67_09"></a>ASYNCHRONOUS EVENTS</h4>
|
|
|
|
<blockquote>
|
|
<p>Default.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_67_10"></a>STDOUT</h4>
|
|
|
|
<blockquote>
|
|
<p>The following formats shall be used when the <i>LC_MESSAGES</i> locale category specifies the POSIX locale. In other locales,
|
|
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
|
|
corresponding to the locale.</p>
|
|
|
|
<pre>
|
|
<tt>"uid=%u(%s) gid=%u(%s)\n", <</tt><i>real user ID</i><tt>>, <</tt><i>user-name</i><tt>>,
|
|
<</tt><i>real group ID</i><tt>>, <</tt><i>group-name</i><tt>>
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>If the effective and real user IDs do not match, the following shall be inserted immediately before the <tt>'\n'</tt> character
|
|
in the previous format:</p>
|
|
|
|
<pre>
|
|
<tt>" euid=%u(%s)"
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>with the following arguments added at the end of the argument list:</p>
|
|
|
|
<pre>
|
|
<tt><</tt><i>effective user ID</i><tt>>, <</tt><i>effective user-name</i><tt>>
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>If the effective and real group IDs do not match, the following shall be inserted directly before the <tt>'\n'</tt> character in
|
|
the format string (and after any addition resulting from the effective and real user IDs not matching):</p>
|
|
|
|
<pre>
|
|
<tt>" egid=%u(%s)"
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>with the following arguments added at the end of the argument list:</p>
|
|
|
|
<pre>
|
|
<tt><</tt><i>effective group-ID</i><tt>>, <</tt><i>effective group name</i><tt>>
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>If the process has supplementary group affiliations or the selected user is allowed to belong to multiple groups, the first
|
|
shall be added directly before the <newline> in the format string:</p>
|
|
|
|
<pre>
|
|
<tt>" groups=%u(%s)"
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>with the following arguments added at the end of the argument list:</p>
|
|
|
|
<pre>
|
|
<tt><</tt><i>supplementary group ID</i><tt>>, <</tt><i>supplementary group name</i><tt>>
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>and the necessary number of the following added after that for any remaining supplementary group IDs:</p>
|
|
|
|
<pre>
|
|
<tt>",%u(%s)"
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>and the necessary number of the following arguments added at the end of the argument list:</p>
|
|
|
|
<pre>
|
|
<tt><</tt><i>supplementary group ID</i><tt>>, <</tt><i>supplementary group name</i><tt>>
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>If any of the user ID, group ID, effective user ID, effective group ID, or supplementary/multiple group IDs cannot be mapped by
|
|
the system into printable user or group names, the corresponding <tt>"(%s)"</tt> and <i>name</i> argument shall be omitted from the
|
|
corresponding format string.</p>
|
|
|
|
<p>When any of the options are specified, the output format shall be as described in the OPTIONS section.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_67_11"></a>STDERR</h4>
|
|
|
|
<blockquote>
|
|
<p>The standard error shall be used only for diagnostic messages.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_67_12"></a>OUTPUT FILES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_67_13"></a>EXTENDED DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_67_14"></a>EXIT STATUS</h4>
|
|
|
|
<blockquote>
|
|
<p>The following exit values shall be returned:</p>
|
|
|
|
<dl compact>
|
|
<dt> 0</dt>
|
|
|
|
<dd>Successful completion.</dd>
|
|
|
|
<dt>>0</dt>
|
|
|
|
<dd>An error occurred.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_67_15"></a>CONSEQUENCES OF ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>Default.</p>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_04_67_16"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>Output produced by the <b>-G</b> option and by the default case could potentially produce very long lines on systems that
|
|
support large numbers of supplementary groups. (On systems with user and group IDs that are 32-bit integers and with group names
|
|
with a maximum of 8 bytes per name, 93 supplementary groups plus distinct effective and real group and user IDs could theoretically
|
|
overflow the 2048-byte {LINE_MAX} text file line limit on the default output case. It would take about 186 supplementary groups to
|
|
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
|
|
is a concern, applications should consider using <a href="../utilities/fold.html"><i>fold</i></a> <b>-s</b> before postprocessing
|
|
the output of <i>id</i>.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_67_17"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_67_18"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>The functionality provided by the 4 BSD <i>groups</i> utility can be simulated using:</p>
|
|
|
|
<pre>
|
|
<tt>id -Gn [ user ]
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>The 4 BSD command <i>groups</i> was considered, but it was not included because it did not provide the functionality of the
|
|
<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
|
|
functionality necessary to systems with multiple groups than to invent another command.</p>
|
|
|
|
<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
|
|
substitution. Without these options it is necessary to use some preprocessor such as <a href="../utilities/sed.html"><i>sed</i></a>
|
|
to select the desired piece of information. Since output such as that produced by:</p>
|
|
|
|
<pre>
|
|
<tt>id -u -n
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>is frequently wanted, it seemed desirable to add the options.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_67_19"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_67_20"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="fold.html"><i>fold</i></a> , <a href="logname.html"><i>logname</i></a> , <a href="who.html"><i>who</i></a> , the System
|
|
Interfaces volume of IEEE Std 1003.1-2001, <a href="../functions/getgid.html"><i>getgid</i>()</a>, <a href=
|
|
"../functions/getgroups.html"><i>getgroups</i>()</a>, <a href="../functions/getuid.html"><i>getuid</i>()</a></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_67_21"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 2.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® is a registered Trademark of The IEEE.<br>
|
|
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
|
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
|
]</font></center>
|
|
|
|
<!--footer end-->
|
|
<hr size="2" noshade>
|
|
</body>
|
|
</html>
|
|
|