2 .\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved
3 .\" Copyright 1989 AT&T
4 .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
5 .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
6 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
7 .\" http://www.opengroup.org/bookstore/.
8 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions 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.
9 .\" This notice shall appear on any product containing this material.
10 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
11 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
12 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
13 .TH NEWGRP 1 "Nov 2, 2007"
15 newgrp \- log in to a new group
20 \fB/usr/bin/newgrp\fR [\fB-|\fR \fB-l\fR] [\fIgroup\fR]
26 \fBnewgrp\fR [\fIargument\fR]
32 \fB*newgrp\fR [\fIargument\fR]
38 \fB+newgrp\fR [\fIargument\fR]
45 The \fBnewgrp\fR command logs a user into a new group by changing a user's real
46 and effective group ID. The user remains logged in and the current directory is
47 unchanged. The execution of \fBnewgrp\fR always replaces the current shell with
48 a new shell, even if the command terminates with an error (unknown group).
51 Any variable that is not exported is reset to null or its default value.
52 Exported variables retain their values. System variables (such as \fBPS1\fR,
53 \fBPS2\fR, \fBPATH\fR, \fBMAIL\fR, and \fBHOME\fR), are reset to default values
54 unless they have been exported by the system or the user. For example, when a
55 user has a primary prompt string (\fBPS1\fR) other than \fB$\fR (default) and
56 has not exported \fBPS1\fR, the user's \fBPS1\fR is set to the default prompt
57 string \fB$\fR, even if \fBnewgrp\fR terminates with an error. Note that the
58 shell command \fBexport\fR (see \fBsh\fR(1) and \fBset\fR(1)) is the method to
59 export variables so that they retain their assigned value when invoking new
63 With no operands and options, \fBnewgrp\fR changes the user's group IDs (real
64 and effective) back to the group specified in the user's password file entry.
65 This is a way to exit the effect of an earlier \fBnewgrp\fR command.
68 A password is demanded if the group has a password and the user is not listed
69 in \fB/etc/group\fR as being a member of that group. The only way to create a
70 password for a group is to use \fBpasswd\fR(1), then cut and paste the password
71 from \fB/etc/shadow\fR to \fB/etc/group\fR. Group passwords are antiquated and
76 Equivalent to \fBexec\fR \fBnewgrp\fR \fIargument\fR where \fIargument\fR
77 represents the options and/or operand of the \fBnewgrp\fR command.
81 Equivalent to \fBexec\fR to\fB/bin/newgrp\fR \fIargument\fR where
82 \fIargument\fR represents the options and/or operand of the \fBnewgrp\fR
86 On this man page, \fBksh\fR(1) commands that are preceded by one or two \fB*\fR
87 (asterisks) are treated specially in the following ways:
91 Variable assignment lists preceding the command remain in effect when the
97 I/O redirections are processed after variable assignments.
102 Errors cause a script that contains them to abort.
107 Words, following a command preceded by \fB**\fR that are in the format of a
108 variable assignment, are expanded with the same rules as a variable assignment.
109 This means that tilde substitution is performed after the \fB=\fR sign and word
110 splitting and file name generation are not performed.
115 Equivalent to \fBexec\fR to\fB/bin/newgrp\fR \fIargument\fR where
116 \fIargument\fR represents the options and/or operand of the \fBnewgrp\fR
120 On this man page, \fBksh93\fR(1) commands that are preceded by one or two
121 \fB+\fR (plus signs) are treated specially in the following ways:
125 Variable assignment lists preceding the command remain in effect when the
131 I/O redirections are processed after variable assignments.
136 Errors cause a script that contains them to abort.
141 They are not valid function names.
146 Words, following a command preceded by \fB++\fR that are in the format of a
147 variable assignment, are expanded with the same rules as a variable assignment.
148 This means that tilde substitution is performed after the \fB=\fR sign and
149 field splitting and file name generation are not performed.
154 The following option is supported:
158 \fB\fB-l\fR | \fB\(mi\fR\fR
161 Change the environment to what would be expected if the user actually logged in
162 again as a member of the new group.
168 The following operands are supported:
175 A group name from the group database or a non-negative numeric group ID.
176 Specifies the group ID to which the real and effective group IDs is set. If
177 \fIgroup\fR is a non-negative numeric string and exists in the group database
178 as a group name (see \fBgetgrnam\fR(3C)), the numeric group ID associated with
179 that group name is used as the group ID.
188 \fBsh\fR and \fBksh\fR only. Options and/or operand of the \fBnewgrp\fR
192 .SH ENVIRONMENT VARIABLES
195 See \fBenviron\fR(5) for descriptions of the following environment variables
196 that affect the execution of \fBnewgrp\fR: \fBLANG\fR, \fBLC_ALL\fR,
197 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
201 If \fBnewgrp\fR succeeds in creating a new shell execution environment, whether
202 or not the group identification was changed successfully, the exit status is
203 the exit status of the shell. Otherwise, the following exit value is returned:
217 \fB\fB/etc/group\fR\fR
226 \fB\fB/etc/passwd\fR\fR
235 See \fBattributes\fR(5) for descriptions of the following attributes:
236 .SS "/usr/bin/newgrp, ksh, sh"
244 ATTRIBUTE TYPE ATTRIBUTE VALUE
246 Interface Stability Committed
248 Standard See \fBstandards\fR(5).
259 ATTRIBUTE TYPE ATTRIBUTE VALUE
261 Interface Stability Uncommitted
267 \fBlogin\fR(1), \fBksh\fR(1), \fBksh93\fR(1), \fBset\fR(1), \fBsh\fR(1),
268 \fBIntro\fR(3), \fBgetgrnam\fR(3C), \fBgroup\fR(4), \fBpasswd\fR(4),
269 \fBattributes\fR(5), \fBenviron\fR(5), \fBstandards\fR(5)