批量创建用户并设置密码不为相同
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
n
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
n
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
n
in
`
seq
10`
do
userdel -r xcn$n &&\
done
|
本文转自 baishuchao 51CTO博客,原文链接:http://blog.51cto.com/baishuchao/1943811