LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 990|回复: 9

关于pw添加用户的一个疑问

[复制链接]
发表于 2003-11-28 22:28:15 | 显示全部楼层 |阅读模式
用pw useradd lhmm建立一个帐户后,这个帐户的初始密码是什么?
发表于 2003-11-28 22:32:19 | 显示全部楼层
我以前也问过这个问题,但没有人知道。估计是不让知道的。
 楼主| 发表于 2003-11-28 22:38:35 | 显示全部楼层
那我该怎么设置这个用户的初始密码呢?
不会再用passwd lhmm来设一个密码吧。
这样的话,pw还不如useradd来的方便呢
 楼主| 发表于 2003-11-28 22:57:54 | 显示全部楼层
密码不会是随机的吧,只能由root来更改?
发表于 2003-11-28 23:24:40 | 显示全部楼层
pw is useful for script, suppose that you have 500 user to create... with pw, you can let user define password themself.


from man pw:
     -h fd           This option provides a special interface by which interac-
                   tive scripts can set an account password using pw.  Because
                   the command line and environment are fundamentally insecure
                   mechanisms by which programs can accept information, pw
                   will only allow setting of account and group passwords via
                   a file descriptor (usually a pipe between an interactive
                   script and the program).  sh, bash, ksh and perl all pos-
                   sess mechanisms by which this can be done.  Alternatively,
                   pw will prompt for the user's password if -h 0 is given,
                   nominating stdin as the file descriptor on which to read
                   the password.  Note that this password will be read only
                   once and is intended for use by a script rather than for
                   interactive use.  If you wish to have new password confir-
                   mation along the lines of passwd(1), this must be imple-
                   mented as part of an interactive script that calls pw.

                   If a value of `-' is given as the argument fd, then the
                   password will be set to `*', rendering the account inacces-
                   sible via password-based login.
 楼主| 发表于 2003-11-29 00:06:49 | 显示全部楼层
呵呵,还不是很明白。
发表于 2003-11-29 01:37:53 | 显示全部楼层
可能我没写清楚,给你举个实例:

假设你有500新学生入学,你要给每个人都建立一个账号,作为管理员的你该怎么办?正常的办法是写一个script (脚本?),先把每个人的账号一下都建立起来,但是不给定密码,给学生们半天的时间,让他们上机自己给密码,如果有人捣乱抢先的话,你再重新设制被抢账号。PW 的作用是让你写script,useradd/adduser 一类是加一两个人时用。man pw , -h 选项让你可以执行script的同时问你要给定的密码,这样可以防止抢账号。清楚了嘛?
 楼主| 发表于 2003-11-29 07:44:19 | 显示全部楼层
OK,谢谢老大。
发表于 2003-11-29 08:28:01 | 显示全部楼层
好像有一个台湾的网站上有关于加大量用户的文章, haha网站吧!
 楼主| 发表于 2003-11-29 10:42:50 | 显示全部楼层
找不到那个台湾的网站
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表