newgrp(1) newgrp(1)
NAME
newgrp - change to new group
SYNOPSIS
newgrp [-] [group]
DESCRIPTION
The shell built-in newgrp overlays the current shell with /bin/newgrp.
The /bin/newgrp command makes the specified group ID number your
current group ID and overlays itself with a new shell. You terminate
the shell in which you called newgrp by hitting the CTRL-D key.
Note: If newgrp is killed with the DEL key while /bin/newgrp is
replacing the current shell, the shell from which newgrp was
called is terminated as well.
The newgrp command can thus be used to switch to another user group.
This means:
- your access permissions for existing files will be changed to those
of the new group affiliation;
- group access permissions for new files that you create will be
those of the group to which you have switched.
Only the variables that you exported earlier [see export(1)] will be
known in the (new) current shell after the group has been changed.
Variables that have not been exported are either considered undefined
or assigned a default value by the shell [see sh(1)]. Shell variables
such as PATH and HOME are also assigned default values, unless they
have already been exported by the system or were explicitly exported
by you. Also, if user's real user id is not 0, i.e. not root, the file
size limit is set to ULIMIT in /etc/default/login or system default
value if there is no ULIMIT.
Before the call
The /etc/group file must contain an entry for the group that you wish
to switch to. Otherwise, newgrp will terminate with an error message.
The newgrp command can be used to switch to any group to which you
belong, i.e. any group for which your login name appears in the
/etc/group file under the corresponding group entry. If a password has
been defined for this group in the /etc/group file, newgrp expects you
to enter this password before making the switch.
If you are not a member of a group, you can only switch to it if it
has a password. Otherwise, newgrp exits with an error message.
Page 1 Reliant UNIX 5.44 Printed 11/98
newgrp(1) newgrp(1)
OPERANDS
No argument specified:
Changes you back to the group whose group ID (GID) has been
entered for your login name in the /etc/passwd file.
- You may only use this argument if a shell is started for your
login name at login time.
The newgrp command overlays the current shell with a login shell.
Before this shell displays its prompt, it first executes the
/etc/profile and your $HOME/.profile (if present) and switches to
your HOME directory.
In other words, except for the fact that you are now a member of
a new group (the one specified on invoking newgrp), you continue
working in the same environment as the one that applied after you
logged into the system.
- not specified:
newgrp overlays the current shell with /bin/newgrp. The current
directory is not changed; however, the new shell will not be
aware of variables that have not been explicitly exported. Unex-
ported variables are either undefined or assigned a default value
by the shell.
group
Name of the group you wish to switch to. There must be an entry
for this group name in the /etc/group file. The associated group
ID (GID) must already be associated with a login name in the
/etc/passwd file.
If you are not a member of the specified group, there must be a
password defined for the group in the /etc/group file. newgrp
expects you to enter this password before it switches groups.
If there is no password for your login name in the /etc/passwd
file, it is essential that a password exists for the group in the
file /etc/group. The newgrp command expects you to enter this
password before it switches groups.
To switch back to the user group that is entered for you in the
/etc/passwd file, simply call newgrp without a group name.
group not specified:
You are returned to the group whose group ID (GID) is entered in
the /etc/passwd file for your login name.
Page 2 Reliant UNIX 5.44 Printed 11/98
newgrp(1) newgrp(1)
Setting up a group password
If you want to switch to a group of which you are not a member, the
system administrator will have to set up a password for that group.
For the system administrator only
Since no command is available to define a password for a group, you
will have to resort to a few "tricks". Two options are available:
- You can simply copy an encrypted password from the /etc/passwd
file, provided you know its meaning in plain text.
- You can install a "dummy password" in the /etc/passwd file and use
the passwd command to define a password. You then write this
encrypted password into the /etc/group file.
EXIT STATUS
As soon as newgrp generates a new shell environment, its exit status
is the same as the shell's, regardless of whether it is possible to
switch to the new group or not.
>0 An error occurred.
ERROR MESSAGES
Unknown group
This name has not been entered in the /etc/group file.
Sorry
You are not permitted to switch to this group, since you are not
a member of the group, and no password has been defined for it
either.
LOCALE
The LCMESSAGES environment variable governs the language in which
message texts are displayed. If LCMESSAGES is undefined or is defined
as the null string, it defaults to the value of LANG. If LANG is like-
wise undefined or null, the system acts as if it were not internation-
alized.
The LCALL environment variable governs the entire locale. LCALL
takes precedence over all the other environment variables which affect
internationalization.
EXAMPLES
Change to the group with the group name council:
$ newgrp council
$ >newfile
$ chmod 640 newfile
$ ls -lg newfile
-rw-r----- 1 rose council 162 Mar 19 18:34 newfile
Page 3 Reliant UNIX 5.44 Printed 11/98
newgrp(1) newgrp(1)
The new file (newfile) created after the group change is available to
members of the council group as a read-only file.
NOTES
Some differences in behavior may occur when using newgrp, depending on
which shell is being used. The possible differences are not described
specifically.
FILES
/etc/default/login
Contains the default settings for the login(1) command.
/etc/default/passwd
Contains the default settings for the passwd(1) command.
/etc/group
Defines a group name for group IDs entered in the /etc/passwd
file as well as all members allowed in the group.
/etc/passwd
Contains all installed login names and group IDs.
SEE ALSO
exec(1), export(1), ksh(1), login(1), sh(1), defaultpasswd(4),
group(4), login(4), passwd(4), environ(5).
Page 4 Reliant UNIX 5.44 Printed 11/98