[i=s] 本帖最后由 swordxia 于 2010-12-7 16:38 编辑 [/i]
Usage: useradd [options] LOGIN
Options:
-b, --base-dir BASE_DIR base directory for the home directory of the new account
/* 新帐户下主目录中的基本目录 */
-c, --comment COMMENT GECOS field of the new account
/* 用户的注释说明 */
-d, --home-dir HOME_DIR home directory of the new account
/* 用户每次登录系统时所使用的登录目录,可以用来取代默认的/home/username主目录 */
-D, --defaults print or change default useradd configuration
/* 显示或改变默认用户配置 */
-e, --expiredate EXPIRE_DATE expiration date of the new account
/* 帐号失效日期。日期的指定格式MM/DD/YY */
-f, --inactive INACTIVE password inactivity period of the new account
/* 设定从帐号过期到永久停用的天数。当其值为0时帐号到期后会立即被停用。而当值为-1时,帐号不会被停用,系统默认值为-1 */
-g, --gid GROUP name or ID of the primary group of the new account
/* 用户默认的用户组或默认的组ID。该用户组或组ID必须是已经存在的,其默认组ID值为100,即属于user组 */
-G, --groups GROUPS list of supplementary groups of the new account
/* 设定该用户为若干用户组的成员。每个用户组使用“,”分隔,且不可以夹杂空格。组名与-g选项的限制相同,且-g的设定值为用户的第一用户组 */
-h, --help display this help message and exit
/* 显示此帮助信息并且退出 */
-k, --skel SKEL_DIR use this alternative skeleton directory
/* 使用此骨架目录来代替 */
-K, --key KEY=VALUE override /etc/login.defs defaults
/* 覆盖/ etc / login.defs中默认 */
-l, --no-log-init do not add the user to the lastlog and faillog databases
/* 用户最后登录和失败信息不记录到数据库中 */
-m, --create-home create the user's home directory
/* 用户目录如不存在则自动建立。若使用-K选项,则skeleton_dir目录内的文档会复制至此用户目录中,同时/etc/ske1目录下的文档会复制过去。任何在skeleton_dir或/etc/ske1中的目录也同样会在该用户目录下一一建立。-k或-m的默认值是不建立目录及不复制任何文档。 */
-M, --no-create-home do not create the user's home directory
/* 不建立用户主目录,使用/etc/login.defs系统对用户进行设定。 */
-N, --no-user-group do not create a group with the same name as the user
/* 系统默认用户组名称与用户名相同。打开此选项将取消该默认设定。 */
-o, --non-unique allow to create users with duplicate (non-unique) UID
/* 允许创建重复的(非唯一)用户的UID */
-p, --password PASSWORD encrypted password of the new account
/* 新帐号加密 */
-r, --system create a system account
/* 创建系统帐号。系统帐号的UID是比定义在/etc/login.defs中的UID--MIN小的值,UID--MIN的默认值是500 */
-s, --shell SHELL login shell of the new account
/* 指定用户的登录SHELL,系统默认为/bin/bash。 */
-u, --uid UID user ID of the new account
/* 用户的UID值。该数值在系统中必须唯一,且数字不可为负值。0~499传统上预留给系统帐号使用。 */
-U, --user-group create a group with the same name as the user
/* 系统默认用户组与用户名相同。 */
-Z, --selinux-user SEUSER use a specific SEUSER for the SELinux user mapping
/* 使用SELinux的用户映射特定SEUSER */
例一:[root@localhost ~]# useradd -D
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash /* 系统默认的SHELL目录 */
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes
[root@localhost ~]# useradd -D -s /bin/csh
[root@localhost ~]# useradd -D
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/csh /* 这是更改后的SHELL目录 */
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes
[root@localhost ~]#
例二:添加一新用户ST,UID为502,用户组ID为100(user用户组的标识符是100),用户目录为/home/st,用户的默认shell为/bin/bash,帐号的失效日期为二零一零年十二月三十一日。
[root@localhost ~]# useradd st -u 550 -d /home/st -s /bin/bash -e 12/31/10 -g 100
[root@localhost ~]# tail -1 /etc/password
tail: 无法打开"/etc/password" 读取数据: 没有那个文件或目录
[root@localhost ~]# tail -1 /etc/passwd /* 显示/etc/passwd文件最后一行内容 */
st:x:550:100::/home/st:/bin/bash
[root@localhost ~]# tail -1 /etc/shadow /* 显示/etc/shadow文件最后一行内容 */
st:!!:14950:0:99999:7::14950:
[root@localhost ~]# useradd st
useradd: user 'st' already exists


wx-1 于 2010-12-24 11:44:31发表:
帮顶
l460618498 于 2010-12-07 22:48:12发表:
把这个发到命令专区去
jive 于 2010-12-07 20:48:08发表:
学习学习
chqunlin 于 2010-12-07 16:57:08发表:
抢个沙发