'\" t .\" Title: newusers .\" Author: Julianne Frances Haugh .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 2018-07-27 .\" Manual: 系统管理命令 .\" Source: shadow-utils 4.5 .\" Language: Chinese Simplified .\" .TH "NEWUSERS" "8" "2018-07-27" "shadow\-utils 4\&.5" "系统管理命令" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "名称" newusers \- 批量更新和创建新用户 .SH "大纲" .HP \w'\fBnewusers\fR\ 'u \fBnewusers\fR [\fI选项\fR] [\fI文件\fR] .SH "描述" .PP The \fBnewusers\fR command reads a \fIfile\fR (or the standard input by default) and uses this information to update a set of existing users or to create new users\&. Each line is in the same format as the standard password file (see \fBpasswd\fR(5)) with the exceptions explained below: .PP pw_name:pw_passwd:pw_uid:pw_gid:pw_gecos:pw_dir:pw_shell .PP \fIpw_name\fR .RS 4 这是用户的用户名。 .sp It can be the name of a new user or the name of an existing user (or a user created before by \fBnewusers\fR)\&. In case of an existing user, the user\*(Aqs information will be changed, otherwise a new user will be created\&. .RE .PP \fIpw_passwd\fR .RS 4 此字段将被加密然后用于加密后密码的新值。 .RE .PP \fIpw_uid\fR .RS 4 此字段用于定义用户的 UID。 .sp If the field is empty, a new (unused) UID will be defined automatically by \fBnewusers\fR\&. .sp 如果此字段包含一个数字,此数字会用于 UID。 .sp If this field contains the name of an existing user (or the name of a user created before by \fBnewusers\fR), the UID of the specified user will be used\&. .sp 如果一个现有用户更改了 UID,此用户的文件所有权需要手动修复。 .RE .PP \fIpw_gid\fR .RS 4 此字段用于定义用户的主组 ID。 .sp 如果此字段包含一个现有组的组名(或者 \fBnewusers\fR 在前边创建的一个组),此组的 GID 会被用于做此用户的主组 ID。 .sp 如果此字段是一个数字,此数字会被用作此用户的主组 ID。如果没有对应此 GID 的现有组,将会使用此 GID 创建一个新组,名称和用户名相同。 .sp 如果此字段为空,将会使用用户名作为组名,\fBnewusers\fR 自动确定的一个 GID 作为主组 ID 来创建一个新组。 .sp 如果此字段包含一个不存在的组的名字(也没有由 \fBnewusers\fR 在前边创建),将使用指定的组名和 \fBnewusers\fR 自动确定的 GID 创建一个组,并作为用户的主组。 .RE .PP \fIpw_gecos\fR .RS 4 此字段复制到用户的 GECOS 字段。 .RE .PP \fIpw_dir\fR .RS 4 此字段用于定义用户的主目录。 .sp 如果此字段指定的不是现有的目录,将会创建指定的目录,所有权设置为创建或更新的用户及其主组。 .sp 如果现有用户的主目录变更,\fBnewusers\fR 不会移动或者复制旧目录的内容到新位置。这需要手动完成。 .RE .PP \fIpw_shell\fR .RS 4 此字段定义了用户的 shell。对此字段不进行任何检查。 .RE .PP \fBnewusers\fR 首先尝试创建或更改所有指定的用户,然后将这些更改写入用户或组数据库。如果发生错误(除非是在最后写入数据库过程中),不会有任何更改。 .PP During this first pass, users are created with a locked password (and passwords are not changed for the users which are not created)\&. A second pass is used to update the passwords using PAM\&. Failures to update a password are reported, but will not stop the other password updates\&. .PP 此命令一般用于在大型的应用环境中,对大量账户进行一次性更新。 .SH "选项" .PP \fBnewusers\fR 命令可以使用的选项有: .PP \fB\-h\fR, \fB\-\-help\fR .RS 4 现实帮助信息并退出。 .RE .PP \fB\-r\fR, \fB\-\-system\fR .RS 4 创建一个系统账户。 .sp System users will be created with no aging information in /etc/shadow, and their numeric identifiers are chosen in the \fBSYS_UID_MIN\fR\-\fBSYS_UID_MAX\fR range, defined in login\&.defs, instead of \fBUID_MIN\fR\-\fBUID_MAX\fR (and their \fBGID\fR counterparts for the creation of groups)\&. .RE .PP \fB\-R\fR, \fB\-\-root\fR\ \&\fICHROOT_DIR\fR .RS 4 Apply changes in the \fICHROOT_DIR\fR directory and use the configuration files from the \fICHROOT_DIR\fR directory\&. .RE .SH "CAVEATS" .PP 输入文件必须受到保护,因为它包含未加密的密码。 .SH "配置文件" .PP 在 /etc/login\&.defs 中有如下配置变量,可以用来更改此工具的行为: .PP \fBGID_MAX\fR (number), \fBGID_MIN\fR (number) .RS 4 \fBuseradd\fR,\fBgroupadd\fR 或 \fBnewusers\fR 创建的常规组的组 ID 的范围。 .sp \fBGID_MIN\fR 和 \fBGID_MAX\fR 的默认值分别是 1000 和 60000。 .RE .PP \fBMAX_MEMBERS_PER_GROUP\fR (number) .RS 4 每个组条目的最大成员数。达到最大值时,在 /etc/group 开始一个新条目(行)(使用同样的名称,同样的密码,同样的 GID)。 .sp 默认值是 0,意味着组中的成员数没有限制。 .sp 此功能(分割组)允许限制组文件中的行长度。这对于确保 NIS 组的行比长于 1024 字符。 .sp 如果要强制这个限制,可以使用 25。 .sp 注意:分割组可能不受所有工具的支持(甚至在 Shadow 工具集中)。您不应该使用这个变量,除非真的需要。 .RE .PP \fBPASS_MAX_DAYS\fR (number) .RS 4 一个密码可以使用的最大天数。如果密码比这旧,将会强迫更改密码。如果不指定,就假定为 \-1,这会禁用这个限制。 .RE .PP \fBPASS_MIN_DAYS\fR (number) .RS 4 两次更改密码时间的最小间隔。将会拒绝任何早于此的更改密码的尝试。如果不指定,假定为 \-1,将会禁用这个限制。 .RE .PP \fBPASS_WARN_AGE\fR (number) .RS 4 密码过期之前给出警告的天数。0 表示只有只在过期的当天警告,负值表示不警告。如果没有指定,不会给警告。 .RE .PP \fBSUB_GID_MIN\fR (number), \fBSUB_GID_MAX\fR (number), \fBSUB_GID_COUNT\fR (number) .RS 4 If /etc/subuid exists, the commands \fBuseradd\fR and \fBnewusers\fR (unless the user already have subordinate group IDs) allocate \fBSUB_GID_COUNT\fR unused group IDs from the range \fBSUB_GID_MIN\fR to \fBSUB_GID_MAX\fR for each new user\&. .sp The default values for \fBSUB_GID_MIN\fR, \fBSUB_GID_MAX\fR, \fBSUB_GID_COUNT\fR are respectively 100000, 600100000 and 10000\&. .RE .PP \fBSUB_UID_MIN\fR (number), \fBSUB_UID_MAX\fR (number), \fBSUB_UID_COUNT\fR (number) .RS 4 If /etc/subuid exists, the commands \fBuseradd\fR and \fBnewusers\fR (unless the user already have subordinate user IDs) allocate \fBSUB_UID_COUNT\fR unused user IDs from the range \fBSUB_UID_MIN\fR to \fBSUB_UID_MAX\fR for each new user\&. .sp The default values for \fBSUB_UID_MIN\fR, \fBSUB_UID_MAX\fR, \fBSUB_UID_COUNT\fR are respectively 100000, 600100000 and 10000\&. .RE .PP \fBSYS_GID_MAX\fR (number), \fBSYS_GID_MIN\fR (number) .RS 4 \fBuseradd\fR、\fBgroupadd\fR 或 \fBnewusers\fR 创建的系统组的组 ID 的范围。 .sp \fBSYS_GID_MIN\fR 和 \fBSYS_GID_MAX\fR 的默认值分别是 101 和 \fBGID_MIN\fR\-1。 .RE .PP \fBSYS_UID_MAX\fR (number), \fBSYS_UID_MIN\fR (number) .RS 4 \fBuseradd\fR 或 \fBnewusers\fR 创建的系统用户的用户 ID 的范围。 .sp \fBSYS_UID_MIN\fR 和 \fBSYS_UID_MAX\fR 的默认值分别是 101 和 \fBUID_MIN\fR\-1。 .RE .PP \fBUID_MAX\fR (number), \fBUID_MIN\fR (number) .RS 4 \fBuseradd\fR 或 \fBnewusers\fR 创建的普通用户的用户 ID 的范围。 .sp \fBUID_MIN\fR 和 \fBUID_MAX\fR 的默认值分别是 1000 和 60000。 .RE .PP \fBUMASK\fR (number) .RS 4 文件模式创建掩码初始化为此值。如果没有指定,掩码初始化为 022。 .sp \fBuseradd\fR 和 \fBnewusers\fR 使用此掩码设置它们创建的用户主目录的模式。 .sp 也被 \fBpam_umask\fR 用作默认 umask 值。 .RE .SH "文件" .PP /etc/passwd .RS 4 用户账户信息。 .RE .PP /etc/shadow .RS 4 安全用户账户信息。 .RE .PP /etc/group .RS 4 组账户信息。 .RE .PP /etc/gshadow .RS 4 安全组账户信息。 .RE .PP /etc/login\&.defs .RS 4 Shadow 密码套件配置。 .RE .PP /etc/pam\&.d/newusers .RS 4 \fBnewusers\fR 的 PAM 配置。 .RE .PP /etc/subgid .RS 4 Per user subordinate group IDs\&. .RE .PP /etc/subuid .RS 4 Per user subordinate user IDs\&. .RE .SH "参见" .PP \fBlogin.defs\fR(5), \fBpasswd\fR(1), \fBsubgid\fR(5), \fBsubuid\fR(5), \fBuseradd\fR(8)\&.