'\" te .\" Copyright (c) 2007, 2011, Oracle and/or its affiliates.All rights reserved. .\" Copyright 1989 AT&T .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved .\" 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 http://www.opengroup.org/bookstore/. .\" 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.This notice shall appear on any product containing this material. .TH newgrp 1 "2011 年 7 月 12 日" "SunOS 5.11" "用户命令" .SH 名称 newgrp \- 登录到新组 .SH 用法概要 .SS "命令" .LP .nf \fB/usr/bin/newgrp\fR [\fB-|\fR \fB-l\fR] [\fIgroup\fR] .fi .SS "sh Built-in" .LP .nf \fBnewgrp\fR [\fIargument\fR] .fi .SS "ksh88 Built-in" .LP .nf \fB*newgrp\fR [\fIargument\fR] .fi .SS "ksh Built-in" .LP .nf \fB+newgrp\fR [\fIargument\fR] .fi .SH 描述 .SS "命令" .sp .LP \fBnewgrp\fR 命令通过更改用户真实有效的组 ID,将用户登录到新组。用户保留登录状态,当前目录不变。执行 \fBnewgrp\fR 时始终会将当前 shell 替换成新的 shell,即使命令因为错误而终止时也是如此(未知组)。 .sp .LP 任何未导出的变量都会重置为空或其缺省值。导出的变量保留其值。系统变量(如 \fBPS1\fR、\fBPS2\fR、\fBPATH\fR、\fBMAIL\fR 和 \fBHOME\fR)会重置为缺省值,但系统或用户已导出的系统变量不会重置。例如,当用户的主提示字符串 (\fBPS1\fR) 不是 \fB$\fR(缺省设置),并且未导出 \fBPS1\fR 时,用户的 \fBPS1\fR 会设置为缺省的提示字符串 \fB$\fR,即使 \fBnewgrp\fR 因为错误终止时也是如此。请注意,shell 命令 \fBexport\fR(请参见 \fBsh\fR(1) 和 \fBset\fR(1))是用于导出变量的方法,以便在调用新 shell 时这些变量可以保留其已有的赋值。 .sp .LP 不使用操作数和选项时,\fBnewgrp\fR 会将用户真实有效的组 ID 恢复为在用户的口令文件条目中指定的组。这是消除早期 \fBnewgrp\fR 命令影响的一种方式。 .sp .LP 如果组有口令,并且 \fB/etc/group\fR 中未将用户列为该组的成员,则需要提供口令。为组创建口令的唯一方法是使用 \fBpasswd\fR(1),然后将口令从 \fB/etc/shadow\fR 剪切并粘贴到 \fB/etc/group\fR。组口令已废弃,不会经常使用。 .SS "sh Built-in" .sp .LP 等效于 \fBexec\fR \fBnewgrp\fR \fIargument\fR,其中 \fIargument\fR 表示 \fBnewgrp\fR 命令的选项和/或操作数。 .SS "ksh88 Built-in" .sp .LP 等效于 \fBexec\fR \fB/bin/newgrp\fR \fIargument\fR,其中 \fIargument\fR 表示 \fBnewgrp\fR 命令的选项和/或操作数。 .sp .LP 本手册页中,前面带有一个或两个 \fB*\fR(星号)的 \fBksh88\fR(1) 命令会通过以下方式进行特殊处理: .RS +4 .TP 1. 命令完成时,该命令前面的变量赋值列表仍然有效。 .RE .RS +4 .TP 2. 在变量赋值之后处理 I/O 重定向。 .RE .RS +4 .TP 3. 脚本中包含的错误会导致其中止。 .RE .RS +4 .TP 4. 如果字的后面是前面加有 \fB**\fR 的命令且字为变量赋值的格式,则使用与变量赋值相同的规则扩展这些字。这表示在 \fB=\fR 符号之后执行波浪号替换,并且不执行字拆分和文件名生成。 .RE .SS "ksh Built-in" .sp .LP 等效于 \fBexec\fR \fB/bin/newgrp\fR \fIargument\fR,其中 \fIargument\fR 表示 \fBnewgrp\fR 命令的选项和/或操作数。 .sp .LP 在此手册页上,前面带一个或两个 \fB+\fR(加号)的 \fBksh\fR(1) 命令会通过以下方式进行特殊处理: .RS +4 .TP 1. 命令完成时,该命令前面的变量赋值列表仍然有效。 .RE .RS +4 .TP 2. 在变量赋值之后处理 I/O 重定向。 .RE .RS +4 .TP 3. 脚本中包含的错误会导致其中止。 .RE .RS +4 .TP 4. 它们不是有效的函数名称。 .RE .RS +4 .TP 5. 如果字的后面是前面加有 \fB++\fR 的命令且字为变量赋值的格式,则使用与变量赋值相同的规则扩展这些字。这意味着将在 \fB=\fR 符号之后执行波浪号替换,并且不执行字段分割和文件名生成。 .RE .SH 选项 .sp .LP 支持以下选项: .sp .ne 2 .mk .na \fB\fB-l\fR | \fB-\fR\fR .ad .RS 10n .rt 将环境更改为用户以新组成员身份实际重新登录时应有的环境。 .RE .SH 操作数 .sp .LP 支持下列操作数: .sp .ne 2 .mk .na \fB\fIgroup\fR\fR .ad .RS 12n .rt 组数据库中的组名称,或者非负数字组 ID。指定要将真实有效的组 ID 设置成的组 ID。如果 \fIgroup\fR 是一个非负数字字符串,并且以组名称的形式存在于组数据库中(请参见 \fBgetgrnam\fR(3C)),则使用与该组名称关联的数字组 ID 作为组 ID。 .RE .sp .ne 2 .mk .na \fB\fIargument\fR\fR .ad .RS 12n .rt 仅限 \fBsh\fR 和 \fBksh88\fR。\fBnewgrp\fR 命令的选项和/或操作数。 .RE .SH 环境变量 .sp .LP 有关影响 \fBnewgrp\fR 执行的以下环境变量的说明,请参见 \fBenviron\fR(5):\fBLANG\fR、\fBLC_ALL\fR、\fBLC_CTYPE\fR、\fBLC_MESSAGES\fR 和 \fBNLSPATH\fR。 .SH 退出状态 .sp .LP 如果 \fBnewgrp\fR 成功创建了新的 shell 执行环境,那么,不管是否成功更改了组标识,退出状态都是 shell 的退出状态。否则,返回以下退出值: .sp .ne 2 .mk .na \fB\fB>0\fR\fR .ad .RS 6n .rt 出现错误。 .RE .SH 文件 .sp .ne 2 .mk .na \fB\fB/etc/group\fR\fR .ad .RS 15n .rt 系统组文件 .RE .sp .ne 2 .mk .na \fB\fB/etc/passwd\fR\fR .ad .RS 15n .rt 系统口令文件 .RE .SH 属性 .sp .LP 有关下列属性的说明,请参见 \fBattributes\fR(5): .SS "/usr/bin/newgrp, ksh88, sh" .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . 属性类型属性值 _ 可用性system/core-os _ 接口稳定性Committed(已确定) _ 标准请参见 \fBstandards\fR(5)。 .TE .SS "ksh" .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . 属性类型属性值 _ 可用性system/core-os _ 接口稳定性Uncommitted(未确定) .TE .SH 另请参见 .sp .LP \fBlogin\fR(1)、\fBksh\fR(1)、\fBksh88\fR(1)、\fBset\fR(1)、\fBsh\fR(1)、\fBIntro\fR(3)、\fBgetgrnam\fR(3C)、\fBgroup\fR(4)、\fBpasswd\fR(4)、\fBattributes\fR(5)、\fBenviron\fR(5)、\fBstandards\fR(5)