1、批量创建用户
cat adduser.sh
#!/bin/bash
#
for username in $(more users.list)
do
if [ -n $username ]
then
useradd $username -g student -d /pub/home/$username
echo
echo $username"xyz" | passwd --stdin $username
chage -d 0 $username
echo $username "has been created!"
else
echo "The username is null!"
fi
done
2、批量删除用户
cat deluser.sh
#!/bin/bash
#
for username in $(more users.list)
do
if [ -n $username ]
then
userdel $username
echo
echo $username "has been deleted!"
else
echo "The username is null!"
fi
done
3、创建users.list,将需要批量创建的有用户填入,一行一个。