创建用户密码
1 #!/bin/bash
2 for i in `seq 1 10`
3 do
4 read -ep "请输入要创建的用户名" username
5 passwd=`date +%s%N | md5sum | head -c 6`
6 cat /etc/passwd|grep $username >/dev/null
7 if [ $? -eq 0 ]
8 then
9 echo "$username用户已存在"
10 echo -e "1.删除用户\n2.跳过"
11 read -ep "请选择你的操作" num
12 case $num in
13 1)
14 userdel -r $username
15 ;;
16 2)
17 continue
18 ;;
19 esac
20 else
21 useradd $username
22 echo "$username:$passwd"|chpasswd
23 echo "$username,$passwd" >> /root/shell/user.txt
24 fi
25 done
浙公网安备 33010602011771号