- 論壇徽章:
- 0
|
NAME
useradd - create a new user or update default new user information
新增用戶或更新新用戶的默認(rèn)信息
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āng)沒有使用-D選項(xiàng),useradd命令創(chuàng)建的用戶賬號信息將使用命令參數(shù)指定的值和系統(tǒng)默認(rèn)值。根據(jù)命令參數(shù),useradd命令將會更新系統(tǒng)文件并可能創(chuàng)建用戶的home目錄和復(fù)制初始文件到目錄中。
OPTIONS
The options which apple to the useradd command are:
useradd使用的命令行選項(xiàng)
-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.
文本字符串。通常是簡短的登陸描述,或者是當(dāng)前用戶的全名字段。
-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選項(xiàng)沒有指定,-b選項(xiàng)指定BASE_DIR的值。useradd用BASE_DIR加上帳戶名稱來指定用戶的home目錄。如果-m選項(xiàng)沒有指定,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目錄。默認(rèn)使用BASE_DIR加上賬號名稱做為home目錄。如果指定的目錄不存在,則會自動創(chuàng)建目錄。
-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.
指定帳號密碼過期的時間到帳號永久作廢的天數(shù)。當(dāng)值為0時密碼過期則帳號立即作廢。設(shè)置值為-1時取消這項(xiàng)功能。默認(rèn)值是-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
指定用戶的初始登陸群組的名稱或編號。群組的名稱必須存在。群組的編號必須引用一個已經(jīng)存在的組編號。默認(rèn)的群組編號是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.
指定帳號同時也是參數(shù)指定的群組的成員。每個群組名稱之間用逗號分割,中間不允許有空格。這些群組和-g選項(xiàng)指定的群組有同樣的約束。默認(rèn)值是帳戶的初始化群組。
-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目錄不存在就創(chuàng)建用戶的Home目錄。如果有-k選項(xiàng),則目錄SKEL_DIR里面的文件就會復(fù)制到Home目錄,否則就復(fù)制/etc/skel目錄里面的文件到Home目錄。包含在SKEL_DIR或/etc/skel目錄內(nèi)的文件也會一同復(fù)制過來。-k選項(xiàng)只和-m選項(xiàng)一起使用。默認(rèn)的創(chuàng)建用戶帳戶動作不創(chuàng)建任何目錄也不復(fù)制任何文件。
-K, --key KEY=VALUE
Overrides /etc/login.defs defaults (UID_MIN, UID_MAX, UMASK, PASS_MAX_DAYS and others).
覆蓋/etc/login.defs中的默認(rèn)設(shè)置(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文件內(nèi)的默認(rèn)設(shè)置(UID_MIN,UID_MAX,UMASK,PASS_MAX_DAYS設(shè)置等等)。
例如:-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.
允許使用重復(fù)的UID來創(chuàng)建用戶帳號。
-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的名稱。默認(rèn)留空此選項(xiàng)而使用系統(tǒng)設(shè)置的默認(rèn)登陸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.
指定數(shù)值做為用戶帳戶的ID,數(shù)值必須唯一,除非-o選項(xiàng)已經(jīng)指定。數(shù)值不能是負(fù)數(shù)。默認(rèn)的值是大于999和其它賬號已經(jīng)使用的數(shù)值。0至999的值是給系統(tǒng)帳戶使用的。
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
如果命令選項(xiàng)中包括-D選項(xiàng),useradd命令將使用默認(rèn)的預(yù)設(shè)值,或者用命令行指定的值來代替預(yù)設(shè)的默認(rèn)值。當(dāng)前可用的選項(xiàng)有:
-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選項(xiàng)沒有使用,則使用用戶的名稱做為用戶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.
指定用戶的默認(rèn)組名稱或組編號。指定的組名稱必須有效,組的編號也必須是實(shí)際組的編號。
-s, --shell SHELL
The name of the new user's login shell. The named program will be used for all future new user accounts.
用戶登陸后啟動的默認(rèn)shell。以后新增加的用戶也使用這個shell程序。
If no options are apecified, useradd displays the current default values.
如果沒有使用任何選項(xiàng),useradd將使用當(dāng)前默認(rèn)的設(shè)定值。
NOTES
The system administrator is responsible for placing the default user files in the /etc/skel/ directory.
系統(tǒng)管理員必須將用戶的默認(rèn)擁有的文件放置在/etc/skel目錄里面。
CAVEATS
You may not add a user to a NIS group. This must be performed on the NIS server.
并不一定要將用戶加入NIS組,因?yàn)檫@必須執(zhí)行NIS服務(wù)。
Similarly, if the username already exists in an external user datebase such as NIS, useradd will deny the user account creation request.
同樣的,如果用戶名稱已經(jīng)存在于擴(kuò)展用戶數(shù)據(jù)庫,例如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_-]*[$]
用戶名稱的第一個字母必須是小寫英文字母,下劃線,虛線或美元符號等。用戶名稱的命名規(guī)則必須滿足正則表達(dá)式:[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博客,如果查看原文請點(diǎn):http://blog.chinaunix.net/u/24950/showart_184384.html |
|