#!/bin/bash
#创建和删除用户,创建的用户默认密码为123456
user=(/etc/passwd)
echo "**************Configure Menu***************"
echo "** 1.Create User **"
echo "** 2.Delete User **"
echo "*******************************************"
read -p "Please enter the number:" vlan
case $vlan in
1)
sleep 1
for vlan in $user
do
read -p "Please enter to create the user": user
useradd $user |echo "123456" |passwd --stdin $user
if [ $? -le 0 ]
then
sleep 1
echo "Creating a successful!"
fi
done
;;
2)
sleep 1
for vlan in $user
do
read -p "Please enter the user to delete": user
userdel $user
if [ $? -le 0 ]
then
sleep 1
echo "Delete the success!"
fi
done
esac
判断用户的密码过期时间
#!/bin/bash
#判断用户名的密码过期时间
vlan=$(cat /etc/login.defs |grep --color=auto PASS_MAX_DAYS |grep -v ^# |awk ‘{print $2}‘)
if [ $vlan -gt 60 ]
then
sleep 1
echo "Password expiration time:$vlan days!"
else
echo "Password expiration time$vlan days!"
fi