批量创建10个系统帐号tianda01-tianda10并设置密码
#、添加用户
useradd tianda01 #、非交互式给密码
echo "pass"|passwd --stdin tianda #、- 加0思路
()echo {..} ()seq -w #随机密码6种方法
()echo $RANDOM | md5sum | cut -c - ()yum -y install expect
mkpasswd -l -d #expect随机 mkpasswd -l -d #expect随机 ()openssl rand -base64 #openssl产生随机数 ()date +%s%N #通过时间获取随机数 ()head /dev/urandom|cksum #设备随机数 ()cat /proc/sys/kernel/random/uuid #uuid随机数 #、for 循环 for 变量 in 变量列表
do
指令
done
脚本如下:
#!/bin/sh
[ -f /etc/init.d/functions ] && source /etc/init.d/functions #引用系统函数库
[$UID -ne ]&&{
echo "Ples sudo - root"
exit
}
#判断是否是root操作,否则退出 for user in tianda{..}
do
word=$(grep "\b$user\b /etc/passwd|wd -l")
if [$word -eq ];then
action "Useradd $user already exists" /bin/false
continue #跳出本次循环
fi pass=$(echo $RANDOM | md5sum | cut -c -) #8位随机密码
useradd $user && \
echo "$pass" |passwd --stdin $user &>/dev/null #把密码交给那个用户 ERTVAL=$? #返回值
if [$ERTVAL -eq ];then #判断返回值
action "Useradd $user IS OK" /bin/true
fi
echo -e "\003[32m"$user"]033[0m \t \033[31m"$pass"\033[0m" >>/tmp/user.txt
done
批量创建10个系统帐号tianda01-tianda10并设置密码的更多相关文章
- shell脚本,批量创建10个系统帐号并设置密码为随机8位字符串。
[root@localhost wyb]# cat user10.sh #!/bin/bash #批量创建10个系统帐号wangyb01-wangyb10并设置密码(密码为随机8位字符串). > ...
- 基于Andoird 4.2.2的Account Manager源代码分析学习:创建选定类型的系统帐号
AccountManager.addAccount() public AccountManagerFuture<Bundle> addAccount(final String accoun ...
- 批量创建10个用户stu01-stu10
1.批量创建10个用户stu01-stu10,并且设置随机8位密码,要求不能用shell循环(例如:for,while等),只能用命令及管道实现. ##方法1: [root@server tmp]# ...
- shell脚本,在指定目录下通过随机小写10个字母加固定字符串oldboy批量创建10个html文件。
[root@localhost wyb]# cat test10.sh #!/bin/bash #使用for循环在/test10目录下通过随机小写10个字母加固定字符串oldboy批量创建10个htm ...
- Mongodb 创建管理员帐号与普通帐号
数据库操作权限 readAnyDatabase 任何数据库的只读权限 userAdminAnyDatabase 任何数据库的读写权限 userAdminAnyDatabase 任何数据库用户的管理权限 ...
- 批量硬关联本地AD帐号与Office云端帐号
世纪互联给的方案, 说只能一个一个做硬匹配, 把我吓尿了. 我整个简单的, 还能批量做. 1. 将本地域中所有用户的这两个属性导出. Get-ADUser -Filter * -SearchBase ...
- shell批量创建用户随机密码
批量创建用户随机密码企业面试题3:批量创建10个系统帐号usr01-usr10并设置密码(密码为随机8位字符串). #! /bin/bash . /etc/init.d/functions Path= ...
- 运维派 企业面试题4&5 创建10个 用户 ; ping探测主机是否在线
Linux运维必会的实战编程笔试题(19题) 企业面试题4: 批量创建10个系统帐号oldboy01-oldboy10并设置密码(密码为随机8位字符串). #!/bin/bash # ;i<=; ...
- Chapter 2 User Authentication, Authorization, and Security(2):创建登录帐号
原文出处:http://blog.csdn.net/dba_huangzj/article/details/38705965,专题目录:http://blog.csdn.net/dba_huangzj ...
随机推荐
- [luogu3413]萌数
[luogu3413]萌数 luogu 考虑数位dp 怎么判断一个数是不是萌数? 只要知道其中某一位和它的前一位相等或者和前一位的前一位相等,那么它就是一个萌数 什么样的数不是萌数? 对于它的每一位都 ...
- redis持久化AOF详细操作步骤
1.切换到redis目录下面,创建文件 s3-redis.conf 2.编辑文件s3-redis.conf 3.终止当前redis服务端 4.登录redis客户端失败,说明服务端已停止 5.重启red ...
- centos7 使用 maven
http://www.cnblogs.com/jackluo/archive/2013/02/06/2901816.html
- python3的时间日期处理
1.python3日期和时间 Python 程序能用很多方式处理日期和时间,转换日期格式是一个常见的功能. Python 提供了一个 time 和 calendar 模块可以用于格式化日期和时间. 时 ...
- QT修改应用程序图标
要准备一个ico的图标,必须是ico格式,切记!! 可以用png或者其他的在线转换:http://www.easyicon.net/covert/ 用记事本 新建文件icon.rc,内容为: IDI_ ...
- Data Structure Binary Tree: Construct Full Binary Tree from given preorder and postorder traversals
http://www.geeksforgeeks.org/full-and-complete-binary-tree-from-given-preorder-and-postorder-travers ...
- Docker alpine 设置东八时区
FROM alpine:3.8 RUN echo 'http://mirrors.ustc.edu.cn/alpine/v3.5/main' > /etc/apk/repositories &a ...
- 【leetcode刷题笔记】Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If ...
- Android系统篇之—-编写系统服务并且将其编译到系统源码中【转】
本文转载自:http://www.wjdiankong.cn/android%E7%B3%BB%E7%BB%9F%E7%AF%87%E4%B9%8B-%E7%BC%96%E5%86%99%E7%B3% ...
- runtime 实现方法交换 viewwillappear方法
1.新建分类 #import "UIViewController+swizzling.h"#import <objc/runtime.h> @implementatio ...