NEWGRP(1)                  POSIX Programmer's Manual                 NEWGRP(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
       newgrp -- change to a new group

SSYYNNOOPPSSIISS
       newgrp [[-l]] [[_g_r_o_u_p]]

DDEESSCCRRIIPPTTIIOONN
       The _n_e_w_g_r_p utility shall create a new shell execution environment with
       a new real and effective group identification. Of the attributes listed
       in _S_e_c_t_i_o_n _2_._1_2, _S_h_e_l_l _E_x_e_c_u_t_i_o_n _E_n_v_i_r_o_n_m_e_n_t, the new shell execution
       environment shall retain the working directory, file creation mask, and
       exported variables from the previous environment (that is, open files,
       traps, unexported variables, alias definitions, shell functions, and
       _s_e_t options may be lost). All other aspects of the process environment
       that are preserved by the _e_x_e_c family of functions defined in the
       System Interfaces volume of POSIX.1-2017 shall also be preserved by
       _n_e_w_g_r_p; whether other aspects are preserved is unspecified.

       A failure to assign the new group identifications (for example, for
       security or password-related reasons) shall not prevent the new shell
       execution environment from being created.

       The _n_e_w_g_r_p utility shall affect the supplemental groups for the process
       as follows:

        *  On systems where the effective group ID is normally in the
           supplementary group list (or whenever the old effective group ID
           actually is in the supplementary group list):

           --  If the new effective group ID is also in the supplementary
               group list, _n_e_w_g_r_p shall change the effective group ID.

           --  If the new effective group ID is not in the supplementary group
               list, _n_e_w_g_r_p shall add the new effective group ID to the list,
               if there is room to add it.

        *  On systems where the effective group ID is not normally in the
           supplementary group list (or whenever the old effective group ID is
           not in the supplementary group list):

           --  If the new effective group ID is in the supplementary group
               list, _n_e_w_g_r_p shall delete it.

           --  If the old effective group ID is not in the supplementary list,
               _n_e_w_g_r_p shall add it if there is room.

       NNoottee::     The System Interfaces volume of POSIX.1-2017 does not specify
                 whether the effective group ID of a process is included in
                 its supplementary group list.

       With no operands, _n_e_w_g_r_p shall change the effective group back to the
       groups identified in the user's user entry, and shall set the list of
       supplementary groups to that set in the user's group database entries.

       If the first argument is ''--'', the results are unspecified.

       If a password is required for the specified group, and the user is not
       listed as a member of that group in the group database, the user shall
       be prompted to enter the correct password for that group. If the user
       is listed as a member of that group, no password shall be requested.
       If no password is required for the specified group, it is
       implementation-defined whether users not listed as members of that
       group can change to that group. Whether or not a password is required,
       implementation-defined system accounting or security mechanisms may
       impose additional authorization restrictions that may cause _n_e_w_g_r_p to
       write a diagnostic message and suppress the changing of the group
       identification.

OOPPTTIIOONNSS
       The _n_e_w_g_r_p 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, except for the
       unspecified usage of ''--''.

       The following option shall be supported:

       --ll        (The letter ell.) Change the environment to what would be
                 expected if the user actually logged in again.

OOPPEERRAANNDDSS
       The following operand shall be supported:

       _g_r_o_u_p     A group name from the group database or a non-negative
                 numeric group ID. Specifies the group ID to which the real
                 and effective group IDs shall be set. If _g_r_o_u_p is a non-
                 negative numeric string and exists in the group database as a
                 group name (see _g_e_t_g_r_n_a_m()), the numeric group ID associated
                 with that group name shall be used as the group ID.

SSTTDDIINN
       Not used.

IINNPPUUTT FFIILLEESS
       The file //ddeevv//ttttyy shall be used to read a single line of text for
       password checking, when one is required.

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

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

       _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
       Not used.

SSTTDDEERRRR
       The standard error shall be used for diagnostic messages and a prompt
       string for a password, if one is required. Diagnostic messages may be
       written in cases where the exit status is not available. See the EXIT
       STATUS section.

OOUUTTPPUUTT FFIILLEESS
       None.

EEXXTTEENNDDEEDD DDEESSCCRRIIPPTTIIOONN
       None.

EEXXIITT SSTTAATTUUSS
       If _n_e_w_g_r_p succeeds in creating a new shell execution environment,
       whether or not the group identification was changed successfully, the
       exit status shall be the exit status of the shell. Otherwise, the
       following exit value shall be returned:

       >0    An error occurred.

CCOONNSSEEQQUUEENNCCEESS OOFF EERRRROORRSS
       The invoking shell may terminate.

       _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
       There is no convenient way to enter a password into the group database.
       Use of group passwords is not encouraged, because by their very nature
       they encourage poor security practices. Group passwords may disappear
       in the future.

       A common implementation of _n_e_w_g_r_p is that the current shell uses _e_x_e_c
       to overlay itself with _n_e_w_g_r_p, which in turn overlays itself with a new
       shell after changing group.  On some implementations, however, this may
       not occur and _n_e_w_g_r_p may be invoked as a subprocess.

       The _n_e_w_g_r_p command is intended only for use from an interactive
       terminal. It does not offer a useful interface for the support of
       applications.

       The exit status of _n_e_w_g_r_p is generally inapplicable. If _n_e_w_g_r_p is used
       in a script, in most cases it successfully invokes a new shell and the
       rest of the original shell script is bypassed when the new shell exits.
       Used interactively, _n_e_w_g_r_p displays diagnostic messages to indicate
       problems. But usage such as:


           newgrp foo
           echo $?

       is not useful because the new shell might not have access to any status
       _n_e_w_g_r_p may have generated (and most historical systems do not provide
       this status). A zero status echoed here does not necessarily indicate
       that the user has changed to the new group successfully. Following
       _n_e_w_g_r_p with the _i_d command provides a portable means of determining
       whether the group change was successful or not.

EEXXAAMMPPLLEESS
       None.

RRAATTIIOONNAALLEE
       Most historical implementations use one of the _e_x_e_c functions to
       implement the behavior of _n_e_w_g_r_p.  Errors detected before the _e_x_e_c
       leave the environment unchanged, while errors detected after the _e_x_e_c
       leave the user in a changed environment. While it would be useful to
       have _n_e_w_g_r_p issue a diagnostic message to tell the user that the
       environment changed, it would be inappropriate to require this change
       to some historical implementations.

       The password mechanism is allowed in the group database, but how this
       would be implemented is not specified.

       The _n_e_w_g_r_p utility was retained in this volume of POSIX.1-2017, even
       given the existence of the multiple group permissions feature in the
       System Interfaces volume of POSIX.1-2017, for several reasons. First,
       in some implementations, the group ownership of a newly created file is
       determined by the group of the directory in which the file is created,
       as allowed by the System Interfaces volume of POSIX.1-2017; on other
       implementations, the group ownership of a newly created file is
       determined by the effective group ID. On implementations of the latter
       type, _n_e_w_g_r_p allows files to be created with a specific group
       ownership. Finally, many implementations use the real group ID in
       accounting, and on such systems, _n_e_w_g_r_p allows the accounting identity
       of the user to be changed.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _C_h_a_p_t_e_r _2, _S_h_e_l_l _C_o_m_m_a_n_d _L_a_n_g_u_a_g_e, _s_h

       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, _e_x_e_c, _g_e_t_g_r_n_a_m()

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                            NEWGRP(1)
