编写脚本user.sh,创建10个用户帐号,每个账号设置一个随机密码

阅读 49

2022-01-04

[root@centos7 ~]#cat user.sh
#!/bin/bash
#
#*************************************************************
#Author:                 chenchengpei
#QQ:                     2088346053
#Date:                   2022-01-04
#FileName:               user.sh
#Description:            The test script
#Copyright (C):          2022 All rights reserved
#*************************************************************
for i in {1..10};do
    id user$i &> /dev/null || useradd user$i
    pass=`openssl rand -base64 12`
    echo $pass | passwd --stdin user$i &> /dev/null
    echo user$i:$pass >> user.txt
done

精彩评论(0)

0 0 举报