0
点赞
收藏
分享

微信扫一扫

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

松鼠树屋 2022-01-04 阅读 46
linux运维
[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 条评论