批量生成用户中 --------<<鸟哥的私房菜>>学习日记之一
2015-04-25 00:00
344 查看
在<<鸟哥的私房菜>> 15.1.2中使用addaccount.sh来新建用户
Linux 的版本是Ubuntu 12.10
运行后报错
passwd: unrecognized option '--stdin'
Usage: passwd [options] [LOGIN]
Options:
-a, --all report password status on all accounts
-d, --delete delete the password for the named account
-e, --expire force expire the password for the named account
-h, --help display this help message and exit
-k, --keep-tokens change password only if expired
-i, --inactive INACTIVE set password inactive after expiration
to INACTIVE
-l, --lock lock the password of the named account
-n, --mindays MIN_DAYS set minimum number of days before password
change to MIN_DAYS
-q, --quiet quiet mode
-r, --repository REPOSITORY change password in REPOSITORY repository
-S, --status report password status on the named account
-u, --unlock unlock the password of the named account
-w, --warndays WARN_DAYS set expiration warning days to WARN_DAYS
-x, --maxdays MAX_DAYS set maximim number of days before password
change to MAX_DAYS
实验使用的linux版本是ubuntu 12.10 网上查的资料很多人人说 ubuntu 不支持 --stdin 所以使用这种方法批量生成用户 会出问题
所以改成使用chpasswd 来生成密码
代码如下
Linux 的版本是Ubuntu 12.10
#!/bin/bash groupadd myquotagrp for username in myquota1 myquota2 myquota3 myquota4 quota5 do useradd -g myquotagrp $username echo "password" | passwd --stdin $username done
运行后报错
passwd: unrecognized option '--stdin'
Usage: passwd [options] [LOGIN]
Options:
-a, --all report password status on all accounts
-d, --delete delete the password for the named account
-e, --expire force expire the password for the named account
-h, --help display this help message and exit
-k, --keep-tokens change password only if expired
-i, --inactive INACTIVE set password inactive after expiration
to INACTIVE
-l, --lock lock the password of the named account
-n, --mindays MIN_DAYS set minimum number of days before password
change to MIN_DAYS
-q, --quiet quiet mode
-r, --repository REPOSITORY change password in REPOSITORY repository
-S, --status report password status on the named account
-u, --unlock unlock the password of the named account
-w, --warndays WARN_DAYS set expiration warning days to WARN_DAYS
-x, --maxdays MAX_DAYS set maximim number of days before password
change to MAX_DAYS
实验使用的linux版本是ubuntu 12.10 网上查的资料很多人人说 ubuntu 不支持 --stdin 所以使用这种方法批量生成用户 会出问题
所以改成使用chpasswd 来生成密码
代码如下
#!/bin/bash groupadd myquotagrp for username in myquota1 myquota2 myquota3 myquota4 quota5 do useradd -g myquotagrp $username echo "$username:passwd"|chpasswd done就不会报错
相关文章推荐
- win32汇编 屏幕截图保存BMP 学习笔记<第四篇>之生成BMP文件
- <Linux 私房菜>基础学习篇学习记录(1)基础命令
- LINUX VI编辑器命令行内容说明 &lt;摘自鸟哥的私房菜&gt;
- JBOSS7 学习<二> 控制台添加用户
- <<鸟哥的私房菜>>--读书笔记--vim编辑器
- java学习日记----------------------------------单机版坦克大战<马士兵>
- &lt;liunx 学习&gt; mysql 中新建用户和用户权限
- <<鸟哥的私房菜>>--读书笔记--文件权限
- <<鸟哥的Linux 私房菜>> (1->12) + my
- <<鸟哥的Linux 私房菜>> (1->12) + my
- Accelerated C++学习笔记4—<使用批量数据>
- 黑马程序员-----学习日记<1>------环境配置总结
- php学习日记<1>
- 黑马程序员-----学习日记<4>----基础总结
- 黑马程序员-----学习日记<3>------基础总结2
- 编程日记: 学习:Generic<Programming>:简化异常安全代码
- CentOS学习笔记之<添加用户到sudoers中>
- 黑马程序员-----学习日记<5>----面向对象总结1
- C#学习日记2016-12-22 关于List<T>的使用和说明
- 黑马程序员-----学习日记<2>------基础总结1