批量添加用户
#!/bin/bash
i=1
while [ $i -le 20 ]
do
useradd stu$i
echo "123456" |
passwd --stdin stu$i &> /dev/null
i=$(($i+1))
done
# 删除用户
#!/bin/bash
# 批量删除用户
user=$(cat /etc/passwd | grep "/bin/bash" |
grep -v "root"|grep -v "mysql"|cut -d ":" -f 1)
for u in $user
do
userdel -r $u
done
原文地址:http://www.cnblogs.com/ahwu/p/3729684.html