1NEWGRP(1P) POSIX Programmer's Manual NEWGRP(1P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
11
13 newgrp — change to a new group
14
16 newgrp [−l] [group]
17
19 The newgrp utility shall create a new shell execution environment with
20 a new real and effective group identification. Of the attributes listed
21 in Section 2.12, Shell Execution Environment, the new shell execution
22 environment shall retain the working directory, file creation mask, and
23 exported variables from the previous environment (that is, open files,
24 traps, unexported variables, alias definitions, shell functions, and
25 set options may be lost). All other aspects of the process environment
26 that are preserved by the exec family of functions defined in the Sys‐
27 tem Interfaces volume of POSIX.1‐2008 shall also be preserved by new‐
28 grp; whether other aspects are preserved is unspecified.
29
30 A failure to assign the new group identifications (for example, for
31 security or password-related reasons) shall not prevent the new shell
32 execution environment from being created.
33
34 The newgrp utility shall affect the supplemental groups for the process
35 as follows:
36
37 * On systems where the effective group ID is normally in the supple‐
38 mentary group list (or whenever the old effective group ID actually
39 is in the supplementary group list):
40
41 -- If the new effective group ID is also in the supplementary
42 group list, newgrp shall change the effective group ID.
43
44 -- If the new effective group ID is not in the supplementary group
45 list, newgrp shall add the new effective group ID to the list,
46 if there is room to add it.
47
48 * On systems where the effective group ID is not normally in the sup‐
49 plementary group list (or whenever the old effective group ID is
50 not in the supplementary group list):
51
52 -- If the new effective group ID is in the supplementary group
53 list, newgrp shall delete it.
54
55 -- If the old effective group ID is not in the supplementary list,
56 newgrp shall add it if there is room.
57
58 Note: The System Interfaces volume of POSIX.1‐2008 does not specify
59 whether the effective group ID of a process is included in
60 its supplementary group list.
61
62 With no operands, newgrp shall change the effective group back to the
63 groups identified in the user's user entry, and shall set the list of
64 supplementary groups to that set in the user's group database entries.
65
66 If the first argument is '−', the results are unspecified.
67
68 If a password is required for the specified group, and the user is not
69 listed as a member of that group in the group database, the user shall
70 be prompted to enter the correct password for that group. If the user
71 is listed as a member of that group, no password shall be requested.
72 If no password is required for the specified group, it is implementa‐
73 tion-defined whether users not listed as members of that group can
74 change to that group. Whether or not a password is required, implemen‐
75 tation-defined system accounting or security mechanisms may impose
76 additional authorization restrictions that may cause newgrp to write a
77 diagnostic message and suppress the changing of the group identifica‐
78 tion.
79
81 The newgrp utility shall conform to the Base Definitions volume of
82 POSIX.1‐2008, Section 12.2, Utility Syntax Guidelines, except for the
83 unspecified usage of '−'.
84
85 The following option shall be supported:
86
87 −l (The letter ell.) Change the environment to what would be
88 expected if the user actually logged in again.
89
91 The following operand shall be supported:
92
93 group A group name from the group database or a non-negative
94 numeric group ID. Specifies the group ID to which the real
95 and effective group IDs shall be set. If group is a non-nega‐
96 tive numeric string and exists in the group database as a
97 group name (see getgrnam()), the numeric group ID associated
98 with that group name shall be used as the group ID.
99
101 Not used.
102
104 The file /dev/tty shall be used to read a single line of text for pass‐
105 word checking, when one is required.
106
108 The following environment variables shall affect the execution of new‐
109 grp:
110
111 LANG Provide a default value for the internationalization vari‐
112 ables that are unset or null. (See the Base Definitions vol‐
113 ume of POSIX.1‐2008, Section 8.2, Internationalization Vari‐
114 ables for the precedence of internationalization variables
115 used to determine the values of locale categories.)
116
117 LC_ALL If set to a non-empty string value, override the values of
118 all the other internationalization variables.
119
120 LC_CTYPE Determine the locale for the interpretation of sequences of
121 bytes of text data as characters (for example, single-byte as
122 opposed to multi-byte characters in arguments).
123
124 LC_MESSAGES
125 Determine the locale that should be used to affect the format
126 and contents of diagnostic messages written to standard
127 error.
128
129 NLSPATH Determine the location of message catalogs for the processing
130 of LC_MESSAGES.
131
133 Default.
134
136 Not used.
137
139 The standard error shall be used for diagnostic messages and a prompt
140 string for a password, if one is required. Diagnostic messages may be
141 written in cases where the exit status is not available. See the EXIT
142 STATUS section.
143
145 None.
146
148 None.
149
151 If newgrp succeeds in creating a new shell execution environment,
152 whether or not the group identification was changed successfully, the
153 exit status shall be the exit status of the shell. Otherwise, the fol‐
154 lowing exit value shall be returned:
155
156 >0 An error occurred.
157
159 The invoking shell may terminate.
160
161 The following sections are informative.
162
164 There is no convenient way to enter a password into the group database.
165 Use of group passwords is not encouraged, because by their very nature
166 they encourage poor security practices. Group passwords may disappear
167 in the future.
168
169 A common implementation of newgrp is that the current shell uses exec
170 to overlay itself with newgrp, which in turn overlays itself with a new
171 shell after changing group. On some implementations, however, this may
172 not occur and newgrp may be invoked as a subprocess.
173
174 The newgrp command is intended only for use from an interactive termi‐
175 nal. It does not offer a useful interface for the support of applica‐
176 tions.
177
178 The exit status of newgrp is generally inapplicable. If newgrp is used
179 in a script, in most cases it successfully invokes a new shell and the
180 rest of the original shell script is bypassed when the new shell exits.
181 Used interactively, newgrp displays diagnostic messages to indicate
182 problems. But usage such as:
183
184 newgrp foo
185 echo $?
186
187 is not useful because the new shell might not have access to any status
188 newgrp may have generated (and most historical systems do not provide
189 this status). A zero status echoed here does not necessarily indicate
190 that the user has changed to the new group successfully. Following new‐
191 grp with the id command provides a portable means of determining
192 whether the group change was successful or not.
193
195 None.
196
198 Most historical implementations use one of the exec functions to imple‐
199 ment the behavior of newgrp. Errors detected before the exec leave the
200 environment unchanged, while errors detected after the exec leave the
201 user in a changed environment. While it would be useful to have newgrp
202 issue a diagnostic message to tell the user that the environment
203 changed, it would be inappropriate to require this change to some his‐
204 torical implementations.
205
206 The password mechanism is allowed in the group database, but how this
207 would be implemented is not specified.
208
209 The newgrp utility was retained in this volume of POSIX.1‐2008, even
210 given the existence of the multiple group permissions feature in the
211 System Interfaces volume of POSIX.1‐2008, for several reasons. First,
212 in some implementations, the group ownership of a newly created file is
213 determined by the group of the directory in which the file is created,
214 as allowed by the System Interfaces volume of POSIX.1‐2008; on other
215 implementations, the group ownership of a newly created file is deter‐
216 mined by the effective group ID. On implementations of the latter type,
217 newgrp allows files to be created with a specific group ownership.
218 Finally, many implementations use the real group ID in accounting, and
219 on such systems, newgrp allows the accounting identity of the user to
220 be changed.
221
223 None.
224
226 Chapter 2, Shell Command Language, sh
227
228 The Base Definitions volume of POSIX.1‐2008, Chapter 8, Environment
229 Variables, Section 12.2, Utility Syntax Guidelines
230
231 The System Interfaces volume of POSIX.1‐2008, exec, getgrnam()
232
234 Portions of this text are reprinted and reproduced in electronic form
235 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
236 -- Portable Operating System Interface (POSIX), The Open Group Base
237 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
238 cal and Electronics Engineers, Inc and The Open Group. (This is
239 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
240 event of any discrepancy between this version and the original IEEE and
241 The Open Group Standard, the original IEEE and The Open Group Standard
242 is the referee document. The original Standard can be obtained online
243 at http://www.unix.org/online.html .
244
245 Any typographical or formatting errors that appear in this page are
246 most likely to have been introduced during the conversion of the source
247 files to man page format. To report such errors, see https://www.ker‐
248 nel.org/doc/man-pages/reporting_bugs.html .
249
250
251
252IEEE/The Open Group 2013 NEWGRP(1P)