shell脚本

您所在的位置:网站首页 shell批量添加用户 shell脚本

shell脚本

2023-12-09 15:09| 来源: 网络整理| 查看: 265

指定密码:

#!/bin/bashULIST=$(cat /root/users.txt)      ##/root/users.txt  里面存放的是用户名,一个名一行for UNAME in $ULISTdo    useradd $UNAME    echo "123456" | passwd --stdin $UNAME

done

----------

#!/bin/bashPREFIX="stu"i=1while [ $i -le 20 ]do    useradd ${PREFIX}$i    echo "123456" | passwd --stdin ${PREFIX}$i &> /dev/null    let i++

done

---------------------------------------------------------

随机密码,不保存:

#!/bin/bashfor user in test{01..10}do useradd $user echo `date +%s%N`|md5sum |egrep '.{8}' -o|passwd --stdin $user

done

----------

#!/bin/bashi=1while [ $i -le 10 ]do useradd -r test$i echo `date +%s%N`|md5sum |egrep '.{8}' -o|passwd --stdin test$i let i++

done

---------------------------------------------------------

随机密码,并保存:

#!/bin/bashfor u in la{01..10}do        useradd $u &>/dev/null        if [ $? -eq 0 ]        then                echo "add user is ok"                p=`uuidgen`                echo $p|passwd --stdin $u &>/dev/null                echo "$u:$p" >>/tmp/userlist        else                echo "add user is error"        fi

done

----------

#!/bin/bash source /etc/init.d/functions for i in biu{01..10} do         useradd $i &>/dev/null         if [ $? -eq 0 ]         then                 action "$i" /bin/true                 pass=`uuidgen`                 echo $pass|passwd --stdin $i &>/dev/null                 echo "$i:$pass" >>/tmp/uuulist         else                 action "$i" /bin/false         fi done


【本文地址】


今日新闻


推荐新闻


    CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3