博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
批量创建用户及密码
阅读量:7074 次
发布时间:2019-06-28

本文共 1502 字,大约阅读时间需要 5 分钟。

批量创建用户并设置密码不为相同

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
for 
in 
`
seq 
-w 10`
do
  
useradd 
xcn$n&&\
  
echo 
"root$n"
|
passwd 
--stdin xcn$n
done
 
 
执行结果:
[root@XCN 
for
]
# sh test7.sh 
Changing password 
for 
user xcn01.
passwd
: all authentication tokens updated successfully.
Changing password 
for 
user xcn02.
passwd
: all authentication tokens updated successfully.
Changing password 
for 
user xcn03.
passwd
: all authentication tokens updated successfully.
Changing password 
for 
user xcn04.
passwd
: all authentication tokens updated successfully.
Changing password 
for 
user xcn05.
passwd
: all authentication tokens updated successfully.
Changing password 
for 
user xcn06.
passwd
: all authentication tokens updated successfully.
Changing password 
for 
user xcn07.
passwd
: all authentication tokens updated successfully.
Changing password 
for 
user xcn08.
passwd
: all authentication tokens updated successfully.
Changing password 
for 
user xcn09.
passwd
: all authentication tokens updated successfully.
Changing password 
for 
user xcn10.
passwd
: all authentication tokens updated successfully.

批量创建用户并设置密码为随机

方法1:

1
2
3
4
5
6
7
8
#!/bin/bash
for 
in 
`
seq 
-w 10`
do
  
pass=`
echo 
"$RANDOM"
|md5sum|
cut 
-c 1-8`
  
useradd 
xcn$n&&\
  
echo 
"$pass" 
|
passwd 
--stdin xcn$n
  
echo 
-e 
"xcn$n\t $pass" 
>>
/data/pass
.log 
done

批量删除用户

1
2
3
4
5
#!/bin/bash
for 
in 
`
seq 
10`
do
   
userdel -r  xcn$n &&\
done

本文转自 baishuchao 51CTO博客,原文链接:http://blog.51cto.com/baishuchao/1943811

转载地址:http://guuml.baihongyu.com/

你可能感兴趣的文章
C/MFC如何获得应用程序当前路径(整理)
查看>>
ES5新特性
查看>>
CentOS Mahout部署
查看>>
很简单,但很实用:数组键值的用途
查看>>
libstdc++.so.6: version `GLIBCXX_3.4.21'
查看>>
Ionic2构建iOS应用上传总结
查看>>
TIMESTAMP with ****问题连不上mysql
查看>>
Linux Tomcat 下的项目局域网中访问不了
查看>>
Git详解之三 Git分支(第二部分)
查看>>
linux 下 ant 安装配置
查看>>
数据库 性能对比
查看>>
Linux下curl命令的使用
查看>>
列出目录下所有文件
查看>>
如何利用HTTP缓存提高网页性能
查看>>
在Silverlight中动态绑定页面报表(PageReport)的数据源
查看>>
Oracle审计与数据库防火墙(AVDF)官方文档
查看>>
Spring Custom Bean with BeanPostProcessor
查看>>
Dark Themed Tab View
查看>>
BobMusic
查看>>
谈谈Ms Chart和TeeChart的优缺点
查看>>