- 论坛徽章:
- 0
|
NAME
useradd - create a new user or update default new user information
新增用户或更新新用户的默认信息
SYNOPSIS
useradd [options] LOGIN
useradd -D
useradd -D [options]
DESCRIPTION
When invoked without the -D option, the useradd command creates a new user account using the values specified on the command line and the default values from the system. Depending on command line options, the useradd command will update system files and may also create the new user's home directory and copy initial files.
当没有使用-D选项,useradd命令创建的用户账号信息将使用命令参数指定的值和系统默认值。根据命令参数,useradd命令将会更新系统文件并可能创建用户的home目录和复制初始文件到目录中。
OPTIONS
The options which apple to the useradd command are:
useradd使用的命令行选项
-c, --comment COMMENT
Any text string. It is generally a short description of the login, and is currently used as the field for the user's full name.
文本字符串。通常是简短的登陆描述,或者是当前用户的全名字段。
-b, --base-dir BASE_DIR
The default base directory for the system if -d dir is not specified. BASE_DIR is concatenated with the account name to define the home directory. If the -m option is not used, BASE_DIR must exist.
如果-d选项没有指定,-b选项指定BASE_DIR的值。useradd用BASE_DIR加上帐户名称来指定用户的home目录。如果-m选项没有指定,BASE_DIR的值必须指定。
-d, --home HOME_DIR
The new user will be created using HOME_DIR as the value for the user's login directory. The default is to append the LOGIN name to BASE_DIR and use that as the login directory name. The directory HOME_DIR does not have to exist but will not be created if it is missing.
指定新账号登陆的home目录。默认使用BASE_DIR加上账号名称做为home目录。如果指定的目录不存在,则会自动创建目录。
-e, --expiredate EXPIRE_DATE
The date on which the user account will be disabled. The date is specified in the format YYYY-MM-DD
指定帐户过期的日期。日期的格式采用YYYY-MM-DD的模式。
-f, --inactive INACTIVE
The number of days after a password expires until the account is permanently disabled. A value of 0 disables the account as sonn as the password has expired, and a value of -1 disables the feature. The default value if -1.
指定帐号密码过期的时间到帐号永久作废的天数。当值为0时密码过期则帐号立即作废。设置值为-1时取消这项功能。默认值是-1。
-g, --gid GROUP
The group name or number of the user's initial login group. The group name must exist. A group number must refer to an already existing group. The default group number is 1 or whatever is specified in /etc/default/useradd
指定用户的初始登陆群组的名称或编号。群组的名称必须存在。群组的编号必须引用一个已经存在的组编号。默认的群组编号是1或者在/etc/default/useradd中指定。
-G, --groups GROUP1[,GROUP2,...[GROUPN]]
A list of supplementary groups which the user is also a member of. Each group is separated from the next by a comma, with no intervening whitespace. The groups are subject to the same restrictions as the group given with the -g option. The default is for the user to belong only to the initial group.
指定帐号同时也是参数指定的群组的成员。每个群组名称之间用逗号分割,中间不允许有空格。这些群组和-g选项指定的群组有同样的约束。默认值是帐户的初始化群组。
-h, --help
Display help message and exit.
只显示帮助信息。
-m, --create-home
The user's home directory will be created if it does not exist. The files contained in SkEL_DIR will be copied to the home dirctory if the -k option is used, otherwise the files contained in /etc/skel will be used instead. Any directories contained in SKEL_DIR or /etc/skel will be created in the user's home directory as well. The -k option is only valid in conjunction with the -m option. The default is to not create the directory and to not copy any files.
如果用户的Home目录不存在就创建用户的Home目录。如果有-k选项,则目录SKEL_DIR里面的文件就会复制到Home目录,否则就复制/etc/skel目录里面的文件到Home目录。包含在SKEL_DIR或/etc/skel目录内的文件也会一同复制过来。-k选项只和-m选项一起使用。默认的创建用户帐户动作不创建任何目录也不复制任何文件。
-K, --key KEY=VALUE
Overrides /etc/login.defs defaults (UID_MIN, UID_MAX, UMASK, PASS_MAX_DAYS and others).
覆盖/etc/login.defs中的默认设置(UID_MIN,UIN_MAX,UMASK,PASS_MAX_DAYS等等)
Example: -K PASS_MAX_DAYS=-1 can be used when creating system account to turn off password ageing, even though system account has no password at all. Multiple -K options can be specified, e.g.: -K UID_MIN=100 -K UID_MAX=499
Note: -K UID_MIN=10, UID_MAX=499 doesn't work yet.
覆盖/etc/login.defs文件内的默认设置(UID_MIN,UID_MAX,UMASK,PASS_MAX_DAYS设置等等)。
例如:-K PASS_MAX_DAYS=-1
注意:-K UID_MIN=10, UID_MAX=499是不支持的。
-o, --non-unique
Allow the creation of a user account with a duplicate (non-unique) UID.
允许使用重复的UID来创建用户帐号。
-p, --password PASSWORD
The encrypted password, as returned by crypt(3). The default is to disable the account.
-s, --shell SHELL
The name of the user's login shell. The default is to leave this field blank, whick causes the system to select the default login shell.
用户登陆shell的名称。默认留空此选项而使用系统设置的默认登陆shell。
-u, --uid UID
The numerical value of the user's ID, This value must be unique, unless the -o option is used. The value must be non-negative. The default is to use the smallest ID value greater then 999 and greater than every other user. Values between 0 and 999 are typically reserved for system accounts.
指定数值做为用户帐户的ID,数值必须唯一,除非-o选项已经指定。数值不能是负数。默认的值是大于999和其它账号已经使用的数值。0至999的值是给系统帐户使用的。
Changing the default values
When invoked with the -D option, useradd will either display the current default values, or update the default values from the command line. The valid options are
如果命令选项中包括-D选项,useradd命令将使用默认的预设值,或者用命令行指定的值来代替预设的默认值。当前可用的选项有:
-b HOME_DIR
The initial path prefix for a new user's home directory. The user's name will be affixed to the end of HOME_DIR to create the new directory name if the -d option is not used when creating a new account.
新用户的home目录的路径。如果-d选项没有使用,则使用用户的名称做为用户home目录的名称。
-e EXPIRE_DATE
The date on which the user account is disabled.
用户帐号过期的时间。
-f INACTIVE
The number of days after a password has expired before the account will be disable.
指定用户密码过期后多少天之后用户帐号停用。
-g, --gid GROUP
The group name or ID for a new user's initial group. The named group must exist, and a numerical group ID must have an existing entry.
指定用户的默认组名称或组编号。指定的组名称必须有效,组的编号也必须是实际组的编号。
-s, --shell SHELL
The name of the new user's login shell. The named program will be used for all future new user accounts.
用户登陆后启动的默认shell。以后新增加的用户也使用这个shell程序。
If no options are apecified, useradd displays the current default values.
如果没有使用任何选项,useradd将使用当前默认的设定值。
NOTES
The system administrator is responsible for placing the default user files in the /etc/skel/ directory.
系统管理员必须将用户的默认拥有的文件放置在/etc/skel目录里面。
CAVEATS
You may not add a user to a NIS group. This must be performed on the NIS server.
并不一定要将用户加入NIS组,因为这必须执行NIS服务。
Similarly, if the username already exists in an external user datebase such as NIS, useradd will deny the user account creation request.
同样的,如果用户名称已经存在于扩展用户数据库,例如NIS,useradd将无法新曾用户。
Usernames must begin with a lower case letter or an underscore,dashes, and dollar signs may follow. In regular expression terms: [a-z_][a-z0-9_-]*[$]
用户名称的第一个字母必须是小写英文字母,下划线,虚线或美元符号等。用户名称的命名规则必须满足正则表达式:[a-z_][a-z0-9_-]*[$]
FILES
/etc/passwd
user account information
/etc/shadow
secure user account information
/etc/group
group account information
/etc/default/useradd
default information
/etc/skel/
directory containing default files
/etc/login.defs
shadow password suite configuration
EXIT VALUES
The useradd command exits with the following values:
0 success
1 can't update password file
2 invalid command syntax
3 invalid argument to option
4 UID already in use (add no -o)
6 specified group doesn't exist
9 username already in use
10 can't update group file
12 can't create home directory
13 can't create mail spool
SEE AlSO
chfn(1), chsh(1), passwd(1), crypt(3), groupadd(8), groupdel(8), groupmod(8), login.defs(5), userdel(8), usermod(8).
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/24950/showart_184384.html |
|