shell脚本交互式批量创建用户:
#!/bin/sh
#Interactive bulk user creation
#num:Number of users created
#num>0
declare -i num
read -p 'Please enter the number of users to create:' num
for i in `seq 1 $num`
do
read -p "Please enter the username of the $i user you want to create:" username
useradd $username
echo "Please give the user:$username a password!"
passwd $username
done
shell脚本批量创建用户,用户密码初始化为:123456,第一次登录时强制修改密码
#!/bin/sh
#Create users in batches with an initial password of 123456, and force the password to be changed at the first login
#num:Number of users created
#num>0
declare -i num
read -p 'Please enter the number of users to create:' num
for i in `seq 1 $num`
do
read -p "Please enter the username of the $i user you want to create:" username
useradd $username
echo "The user:$username is initial password is 123456!"
echo 123456 |passwd --stdin $username
chage -d 0 $username
done
来源:CSDN
作者:mxctf_p1@y3r
链接:https://blog.csdn.net/mxctf_p1ay3r/article/details/103802144