Manual pages › System administration commands (1M)
newgrp(1M)
log in to a new group
From the original Amiga UNIX 2.1 manual. Some things it mentions may not be in this release.
NAME
newgrp - log in to a new group
SYNOPSIS
newgrp [-] [ group ]
DESCRIPTION
newgrp changes a user's real and effective group ID. The user remains logged in and the current directory is unchanged. The user is always given a new shell, replacing the current shell, by newgrp, regardless of whether it terminated successfully or due to an error condition (i.e., unknown group).
Exported variables retain their values after invoking newgrp; however, all unexported variables are either reset to their default value or set to null. System variables (such as PS1, PS2, PATH, MAIL, and HOME), unless exported by the system or explicitly exported by the user, are reset to default values. For example, a user has a primary prompt string (PS1) other than $ (default) and has not exported PS1. After an invocation of newgrp, successful or not, the user's PS1 will now be set to the default prompt string $. Note that the shell command export [see the sh(1) manual page] is the method to export variables so that they retain their assigned value when invoking new shells.
With no arguments, newgrp changes the user's group IDs (real and effective) back to the group specified in the user's password file entry. This is a way to exit the effect of an earlier newgrp command.
If the first argument to newgrp is a -, the environment is changed to what would be expected if the user actually logged in again as a member of the new group.
A password is demanded if the group has a password and the user is not listed in /etc/group as being a member of that group.
FILES
/etc/group
system's group file
/etc/passwd
system's password file
SEE ALSO
login(1), sh(1) in the User's Reference Manual. group(4), passwd(4), environ(5) in the System Administrator's Reference Manual. see intro(2) ``Effective User ID and Effective Group ID" in Programmer's Reference Manual