ID(1)                      POSIX Programmer's Manual                     ID(1)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.

NNAAMMEE
       id -- return user identity

SSYYNNOOPPSSIISS
       id [[_u_s_e_r]]

       id -G [[-n]] [[_u_s_e_r]]

       id -g [[-nr]] [[_u_s_e_r]]

       id -u [[-nr]] [[_u_s_e_r]]

DDEESSCCRRIIPPTTIIOONN
       If no _u_s_e_r operand is provided, the _i_d 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 POSIX.1-2017), the supplementary group
       affiliations of the invoking process shall also be written.

       If a _u_s_e_r operand is provided and the process has 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.

OOPPTTIIOONNSS
       The _i_d utility shall conform to the Base Definitions volume of
       POSIX.1-2017, _S_e_c_t_i_o_n _1_2_._2, _U_t_i_l_i_t_y _S_y_n_t_a_x _G_u_i_d_e_l_i_n_e_s.

       The following options shall be supported:

       --GG        Output all different group IDs (effective, real, and
                 supplementary) only, using the format ""%%uu\\nn"".  If there is
                 more than one distinct group affiliation, output each such
                 affiliation, using the format "" %%uu"", before the <newline> is
                 output.

       --gg        Output only the effective group ID, using the format ""%%uu\\nn"".

       --nn        Output the name in the format ""%%ss"" instead of the numeric ID
                 using the format ""%%uu"".

       --rr        Output the real ID instead of the effective ID.

       --uu        Output only the effective user ID, using the format ""%%uu\\nn"".

OOPPEERRAANNDDSS
       The following operand shall be supported:

       _u_s_e_r      The login name for which information is to be written.

SSTTDDIINN
       Not used.

IINNPPUUTT FFIILLEESS
       None.

EENNVVIIRROONNMMEENNTT VVAARRIIAABBLLEESS
       The following environment variables shall affect the execution of _i_d:

       _L_A_N_G      Provide a default value for the internationalization
                 variables that are unset or null. (See the Base Definitions
                 volume of POSIX.1-2017, _S_e_c_t_i_o_n _8_._2, _I_n_t_e_r_n_a_t_i_o_n_a_l_i_z_a_t_i_o_n
                 _V_a_r_i_a_b_l_e_s for the precedence of internationalization
                 variables used to determine the values of locale categories.)

       _L_C___A_L_L    If set to a non-empty string value, override the values of
                 all the other internationalization variables.

       _L_C___C_T_Y_P_E  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).

       _L_C___M_E_S_S_A_G_E_S
                 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.

       _N_L_S_P_A_T_H   Determine the location of message catalogs for the processing
                 of _L_C___M_E_S_S_A_G_E_S.

AASSYYNNCCHHRROONNOOUUSS EEVVEENNTTSS
       Default.

SSTTDDOOUUTT
       The following formats shall be used when the _L_C___M_E_S_S_A_G_E_S locale
       category specifies the POSIX locale. In other locales, the strings _u_i_d,
       _g_i_d, _e_u_i_d, _e_g_i_d, and _g_r_o_u_p_s may be replaced with more appropriate
       strings corresponding to the locale.


           "uid=%u(%s) gid=%u(%s)\n", <_r_e_a_l _u_s_e_r _I_D>, <_u_s_e_r_-_n_a_m_e>,
               <_r_e_a_l _g_r_o_u_p _I_D>, <_g_r_o_u_p_-_n_a_m_e>

       If the effective and real user IDs do not match, the following shall be
       inserted immediately before the ''\\nn'' character in the previous format:


           " euid=%u(%s)"

       with the following arguments added at the end of the argument list:


           <_e_f_f_e_c_t_i_v_e _u_s_e_r _I_D>, <_e_f_f_e_c_t_i_v_e _u_s_e_r_-_n_a_m_e>

       If the effective and real group IDs do not match, the following shall
       be inserted directly before the ''\\nn'' character in the format string
       (and after any addition resulting from the effective and real user IDs
       not matching):


           " egid=%u(%s)"

       with the following arguments added at the end of the argument list:


           <_e_f_f_e_c_t_i_v_e _g_r_o_u_p_-_I_D>, <_e_f_f_e_c_t_i_v_e _g_r_o_u_p _n_a_m_e>

       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:


           " groups=%u(%s)"

       with the following arguments added at the end of the argument list:


           <_s_u_p_p_l_e_m_e_n_t_a_r_y _g_r_o_u_p _I_D>, <_s_u_p_p_l_e_m_e_n_t_a_r_y _g_r_o_u_p _n_a_m_e>

       and the necessary number of the following added after that for any
       remaining supplementary group IDs:


           ",%u(%s)"

       and the necessary number of the following arguments added at the end of
       the argument list:


           <_s_u_p_p_l_e_m_e_n_t_a_r_y _g_r_o_u_p _I_D>, <_s_u_p_p_l_e_m_e_n_t_a_r_y _g_r_o_u_p _n_a_m_e>

       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 ""((%%ss))"" and _n_a_m_e
       argument shall be omitted from the corresponding format string.

       When any of the options are specified, the output format shall be as
       described in the OPTIONS section.

SSTTDDEERRRR
       The standard error shall be used only for diagnostic messages.

OOUUTTPPUUTT FFIILLEESS
       None.

EEXXTTEENNDDEEDD DDEESSCCRRIIPPTTIIOONN
       None.

EEXXIITT SSTTAATTUUSS
       The following exit values shall be returned:

        0    Successful completion.

       >0    An error occurred.

CCOONNSSEEQQUUEENNCCEESS OOFF EERRRROORRSS
       Default.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       Output produced by the --GG 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_d --GG).  This is not expected to be a problem in practice, but in
       cases where it is a concern, applications should consider using _f_o_l_d --ss
       before post-processing the output of _i_d.

EEXXAAMMPPLLEESS
       None.

RRAATTIIOONNAALLEE
       The functionality provided by the 4 BSD _g_r_o_u_p_s utility can be simulated
       using:


           id -Gn [ user ]

       The 4 BSD command _g_r_o_u_p_s was considered, but it was not included
       because it did not provide the functionality of the _i_d utility of the
       SVID. Also, it was thought that it would be easier to modify _i_d to
       provide the additional functionality necessary to systems with multiple
       groups than to invent another command.

       The options --uu, --gg, --nn, and --rr were added to ease the use of _i_d with
       shell commands substitution. Without these options it is necessary to
       use some preprocessor such as _s_e_d to select the desired piece of
       information. Since output such as that produced by:


           id -u -n

       is frequently wanted, it seemed desirable to add the options.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _f_o_l_d, _l_o_g_n_a_m_e, _w_h_o

       The Base Definitions volume of POSIX.1-2017, _C_h_a_p_t_e_r _8, _E_n_v_i_r_o_n_m_e_n_t
       _V_a_r_i_a_b_l_e_s, _S_e_c_t_i_o_n _1_2_._2, _U_t_i_l_i_t_y _S_y_n_t_a_x _G_u_i_d_e_l_i_n_e_s

       The System Interfaces volume of POSIX.1-2017, _g_e_t_g_i_d(), _g_e_t_g_r_o_u_p_s(),
       _g_e_t_u_i_d()

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1-2017, Standard for Information Technology --
       Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the
       Institute of Electrical and Electronics Engineers, Inc and The Open
       Group.  In the event of any discrepancy between this version 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 .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2017                                ID(1)
