newgrp(1)
NAME
newgrp − log in to a new group
SYNOPSIS
newgrp [-] [group]
DESCRIPTION
newgrp changes a user’s group identification without changing the user ID, subject to the following conditions:
• User is a member of the new group, or
• If user is not a member of group, group has a password that is known to user. (If user is not a member of group and there is no group password, newgroup fails.)
The user remains logged in and the current directory is unchanged, but calculations of access permissions to files are performed with respect to the new real and effective group IDs.
newgrp always gives the user a new shell which replaces the current shell (without creating a new process), regardless of whether newgrp terminates successfully or as a result of an error condition (such as an unknown group). The new shell is either:
• The shell specified for that user in /etc/passwd, or
• /bin/sh if the shell field in /etc/passwd is empty for that user.
Exported variables retain their values after invoking newgrp, but all unexported variables are either reset to their default value or set to null. Environment variables such as PS1, PS2, PATH, MAIL, and HOME are reset to default values unless they were previously exported by the system or explicitly exported by the user. For example, assume a user has redefined the primary prompt string PS1 so that it no longer has the default value $, but PS1 has not been exported. newgrp, whether successful or not, sets PS1 to the default prompt string $ as a result of the changed shell. To preserve existing variable names and values when starting new shells, use the built-in export command described in the ksh(1) or sh(1) manual entry (csh(1) does not have a built-in export command).
When newgrp is executed without any arguments, the group identification changes back to the group specified in the user’s password file entry, and a new shell is created, again without starting a new process.
If the first argument to newgrp is -, the user’s .profile file (or .cshrc if csh is specified for the user in /etc/passwd) is executed when the new shell is started, thus changing the environment to what would be expected if the user actually logged in again.
If the user is not listed as a member of group in file /etc/group and the group has a password, a password is required before newgrp can change the effective group ID.
newgrp fails if the user does not qualify as a group member for any of the following reasons:
• User cannot be found in the password file, either by login name or real user id, or
• User was not a member of the new group and:
− group has a password which the user failed to provide, or
− group has no password.
Since no new process is created when the new shell is started, exiting from the new shell has the same effect as exiting the shell from which newgrp was executed.
EXTERNAL INFLUENCES
International Code Set Support
Characters from the 7-bit USASCII code set are supported in group names (see ascii(5)).
DIAGNOSTICS
Sorry: User does not qualify as a group member.
Unknown group: Group name does not exist in /etc/group.
Permission denied: If a password is required, it must come from a teletype port.
You have no shell: Standard input is a non-tty file, causing the exec of the new shell to fail.
WARNINGS
There is no convenient way to enter a password into /etc/group.
Use of group passwords is not recommended because they, by their very nature, encourage poor security practices. Group passwords may be eliminated in future HP-UX releases.
Any shell variables that are not exported are lost.
FILES
/etc/group system group file
/etc/passwd system password file
SEE ALSO
login(1), sh(1), group(4), passwd(4), environ(5).
STANDARDS CONFORMANCE
newgrp: SVID2, XPG2, XPG3
Hewlett-Packard Company — HP-UX Release 9.0: August 1992