1newgrp(1) User Commands newgrp(1)
2
3
4
6 newgrp - log in to a new group
7
9 Command
10 /usr/bin/newgrp [-| -l] [group]
11
12
13 sh Built-in
14 newgrp [argument]
15
16
17 ksh Built-in
18 *newgrp [argument]
19
20
21 ksh93 Built-in
22 +newgrp [argument]
23
24
26 Command
27 The newgrp command logs a user into a new group by changing a user's
28 real and effective group ID. The user remains logged in and the current
29 directory is unchanged. The execution of newgrp always replaces the
30 current shell with a new shell, even if the command terminates with an
31 error (unknown group).
32
33
34 Any variable that is not exported is reset to null or its default
35 value. Exported variables retain their values. System variables (such
36 as PS1, PS2, PATH, MAIL, and HOME), are reset to default values unless
37 they have been exported by the system or the user. For example, when a
38 user has a primary prompt string (PS1) other than $ (default) and has
39 not exported PS1, the user's PS1 is set to the default prompt string $,
40 even if newgrp terminates with an error. Note that the shell command
41 export (see sh(1) and set(1)) is the method to export variables so that
42 they retain their assigned value when invoking new shells.
43
44
45 With no operands and options, newgrp changes the user's group IDs (real
46 and effective) back to the group specified in the user's password file
47 entry. This is a way to exit the effect of an earlier newgrp command.
48
49
50 A password is demanded if the group has a password and the user is not
51 listed in /etc/group as being a member of that group. The only way to
52 create a password for a group is to use passwd(1), then cut and paste
53 the password from /etc/shadow to /etc/group. Group passwords are anti‐
54 quated and not often used.
55
56 sh Built-in
57 Equivalent to exec newgrp argument where argument represents the
58 options and/or operand of the newgrp command.
59
60 ksh Built-in
61 Equivalent to exec to/bin/newgrp argument where argument represents the
62 options and/or operand of the newgrp command.
63
64
65 On this man page, ksh(1) commands that are preceded by one or two *
66 (asterisks) are treated specially in the following ways:
67
68 1. Variable assignment lists preceding the command remain in
69 effect when the command completes.
70
71 2. I/O redirections are processed after variable assignments.
72
73 3. Errors cause a script that contains them to abort.
74
75 4. Words, following a command preceded by ** that are in the
76 format of a variable assignment, are expanded with the same
77 rules as a variable assignment. This means that tilde sub‐
78 stitution is performed after the = sign and word splitting
79 and file name generation are not performed.
80
81 ksh93 Built-in
82 Equivalent to exec to/bin/newgrp argument where argument represents the
83 options and/or operand of the newgrp command.
84
85
86 On this man page, ksh93(1) commands that are preceded by one or two +
87 (plus signs) are treated specially in the following ways:
88
89 1. Variable assignment lists preceding the command remain in
90 effect when the command completes.
91
92 2. I/O redirections are processed after variable assignments.
93
94 3. Errors cause a script that contains them to abort.
95
96 4. They are not valid function names.
97
98 5. Words, following a command preceded by ++ that are in the
99 format of a variable assignment, are expanded with the same
100 rules as a variable assignment. This means that tilde sub‐
101 stitution is performed after the = sign and field splitting
102 and file name generation are not performed.
103
105 The following option is supported:
106
107 -l | − Change the environment to what would be expected if the
108 user actually logged in again as a member of the new
109 group.
110
111
113 The following operands are supported:
114
115 group A group name from the group database or a non-negative
116 numeric group ID. Specifies the group ID to which the real
117 and effective group IDs is set. If group is a non-negative
118 numeric string and exists in the group database as a group
119 name (see getgrnam(3C)), the numeric group ID associated
120 with that group name is used as the group ID.
121
122
123 argument sh and ksh only. Options and/or operand of the newgrp com‐
124 mand.
125
126
128 See environ(5) for descriptions of the following environment variables
129 that affect the execution of newgrp: LANG, LC_ALL, LC_CTYPE, LC_MES‐
130 SAGES, and NLSPATH.
131
133 If newgrp succeeds in creating a new shell execution environment,
134 whether or not the group identification was changed successfully, the
135 exit status is the exit status of the shell. Otherwise, the following
136 exit value is returned:
137
138 >0 An error occurred.
139
140
142 /etc/group System group file
143
144
145 /etc/passwd System password file
146
147
149 See attributes(5) for descriptions of the following attributes:
150
151 /usr/bin/newgrp, ksh, sh
152 ┌─────────────────────────────┬─────────────────────────────┐
153 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
154 ├─────────────────────────────┼─────────────────────────────┤
155 │Availability │SUNWcsu │
156 ├─────────────────────────────┼─────────────────────────────┤
157 │Interface Stability │Committed │
158 ├─────────────────────────────┼─────────────────────────────┤
159 │Standard │See standards(5). │
160 └─────────────────────────────┴─────────────────────────────┘
161
162 ksh93
163 ┌─────────────────────────────┬─────────────────────────────┐
164 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
165 ├─────────────────────────────┼─────────────────────────────┤
166 │Availability │SUNWcsu │
167 ├─────────────────────────────┼─────────────────────────────┤
168 │Interface Stability │Uncommitted │
169 └─────────────────────────────┴─────────────────────────────┘
170
172 login(1), ksh(1), ksh93(1), set(1), sh(1), Intro(3), getgrnam(3C),
173 group(4), passwd(4), attributes(5), environ(5), standards(5)
174
175
176
177SunOS 5.11 2 Nov 2007 newgrp(1)