shell脚本,批量创建10个系统帐号并设置密码为随机8位字符串。
[root@localhost wyb]# cat user10.sh
#!/bin/bash
#批量创建10个系统帐号wangyb01-wangyb10并设置密码(密码为随机8位字符串)。
>user.list
for user in `seq -w `
do useradd wangyb$user
password=`echo $RANDOM|md5sum|cut -c -`
echo $password|passwd wangyb$user --stdin
echo wangyb$user $password >> user.list
done [root@localhost wyb]# bash user10.sh
Creating mailbox file: File exists
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Changing password for user wangyb01.
passwd: all authentication tokens updated successfully.
Creating mailbox file: File exists
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Changing password for user wangyb02.
passwd: all authentication tokens updated successfully.
Creating mailbox file: File exists
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Changing password for user wangyb03.
passwd: all authentication tokens updated successfully.
Creating mailbox file: File exists
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Changing password for user wangyb04.
passwd: all authentication tokens updated successfully.
Creating mailbox file: File exists
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Changing password for user wangyb05.
passwd: all authentication tokens updated successfully.
Creating mailbox file: File exists
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Changing password for user wangyb06.
passwd: all authentication tokens updated successfully.
Creating mailbox file: File exists
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Changing password for user wangyb07.
passwd: all authentication tokens updated successfully.
Creating mailbox file: File exists
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Changing password for user wangyb08.
passwd: all authentication tokens updated successfully.
Creating mailbox file: File exists
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Changing password for user wangyb09.
passwd: all authentication tokens updated successfully.
Creating mailbox file: File exists
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Changing password for user wangyb10.
passwd: all authentication tokens updated successfully.
[root@localhost wyb]# cat user.list
wangyb01 77950e07
wangyb02 ace3cfb1
wangyb03 2cd63081
wangyb04 0f891e3c
wangyb05 600bedd4
wangyb06 73d3dfdc
wangyb07
wangyb08 54cf685f
wangyb09 ee3f88af
wangyb10 b54d2555
[root@localhost wyb]# su wang01
su: user wang01 does not exist
[root@localhost wyb]# su wangyb01
[wangyb01@localhost wyb]$ su wangyb10
Password:
[wangyb10@localhost wyb]$ [root@localhost wyb]# cat deluser10.sh
#!/bin/bash
#批量删除10个系统帐号wangyb01-wangyb10并设置密码(密码为随机8位字符串)。
> user.list
for user in `seq -w `
do userdel wangyb$user
done [root@localhost wyb]# bash deluser10.sh
[root@localhost wyb]# su wangyb01
su: user wangyb01 does not exist
[root@localhost wyb]#
shell脚本,批量创建10个系统帐号并设置密码为随机8位字符串。的更多相关文章
- 批量创建10个系统帐号tianda01-tianda10并设置密码
#.添加用户 useradd tianda01 #.非交互式给密码 echo "pass"|passwd --stdin tianda #.- 加0思路 ()..} () #随机密 ...
- Shell 脚本批量创建数据库表
使用 Shell 脚本批量创建数据表 系统:Centos6.5 64位 MySQL版本:5.1.73 比如下面这个脚本: #!/bin/bash #批量新建数据表 for y in {0..199}; ...
- Linux shell脚本 批量创建多个用户
Linux shell脚本 批量创建多个用户 #!/bin/bash groupadd charlesgroup for username in charles1 charles2 charles3 ...
- 案例九:shell脚本自动创建多个新用户,并设置密码
此脚本是用来批量创建用户并设置用户密码,在企业用非常实用. 脚本一 #!/bin/bash for name in $( seq 1 100 ) do useradd "user$name& ...
- shell脚本批量创建用户
#!/bin/bash DATE=$(date +%F_%T) USER_FILE=user.txt echo_color() { == "green" ];then echo - ...
- 基于Andoird 4.2.2的Account Manager源代码分析学习:创建选定类型的系统帐号
AccountManager.addAccount() public AccountManagerFuture<Bundle> addAccount(final String accoun ...
- shell脚本,在指定目录下通过随机小写10个字母加固定字符串oldboy批量创建10个html文件。
[root@localhost wyb]# cat test10.sh #!/bin/bash #使用for循环在/test10目录下通过随机小写10个字母加固定字符串oldboy批量创建10个htm ...
- linux系统配置文件或shell脚本批量注释
1. 配置文件批量注释 1.1 批量注释 ① 进入命令行模式,按ctrl + v进入 visual block模式,键盘上下箭头选中多行,把需要注释的行标记起来 ② 按大写字母I,再输入注释符:# ③ ...
- 批量创建10个用户stu01-stu10
1.批量创建10个用户stu01-stu10,并且设置随机8位密码,要求不能用shell循环(例如:for,while等),只能用命令及管道实现. ##方法1: [root@server tmp]# ...
随机推荐
- 51nod 1297
思路: 搞个栈模拟一下,也才5w; 直接wa1了..然后想到井口如果都进不去那就...一定GG了. 所以维护一下从井口到井底是非递增的就好了: #include <cstdio> #inc ...
- Metabolic Signatures of Cystic Fibrosis Identified in Dried Blood Spots For Newborn Screening Without Carrier Identification (文献分享一组-孔楠楠)
题目:Metabolic Signatures of Cystic Fibrosis Identified in Dried Blood Spots For Newborn Screening Wit ...
- RobotFramework特性总结
robotframework是一款python编写的功能自动化测试框架.具备良好的可扩展性,支持关键字驱动,可以同时编写多种类型的客户端或者接口,可以进行分布式测试执行.主要用户轮次很多的验收测试和验 ...
- python文件实现增删改查操作
# coding = utf-8 import os import json import re ''' 本程序旨在将练习基础知识部分,包括: 列表,元组,字典,文件,函数,字符串等知识 实现的功能: ...
- mysql状态查询
在监控中,都是去探测这些状态数据,然后换算到时间刻度上,像zabbix. show status like 'uptime'; --查看select语句的执行数 show [global] statu ...
- Zynq7000开发系列-5(OpenCV开发环境搭建:Ubuntu、Zynq)
操作系统:Ubuntu14.04.5 LTS 64bit OpenCV:OpenCV 3.1.0.opencv_contrib gcc:gcc version 4.8.4 (Ubuntu 4.8.4- ...
- Tinghua Data Mining 4
贝叶斯 决策树 知道三文鱼和金枪鱼颜色 让你去猜 B命中的概率不能直接减去四分之三 因为有可能同时命中 A B 命中不是互斥事件 即便体检报告是阳性,真正得癌症的概率也很小,只有0.21 绝大多数的阳 ...
- CSS浮动float父div没有高度的问题
如下所示,子元素 div2 本身具有高度和宽度,但由于其具有float:left:属性后.其父元素 div1 不具有高度. <html> <head> </h ...
- php出现Warning: file_put_contents,failed to open stream
Warning: file_put_contents(D:/wwwroot/jinxiongdi/web/temp/caches/f/index_40F756F0.php) [function.fil ...
- Navicate Premium连接Oracle数据库报错
Navicat Premium连接MySQL数据库没有问题,在连接Oracle数据库的时候报错,提示:ORA-28547:connection to server failed,probable Or ...