vim /root/bin/nologin.sh
!/bin/bash
read -p "请输入用户名:" username
A=/bin/bash
B=grep "^$username" /etc/passwd | cut -d: -f7
C=grep "^$username" /etc/passwd| cut -d: -f 3
D=grep "^$username" /etc/passwd
if [ $? -ne 0 ];then
echo "系统无此用户..."
elif [ $C -lt 1000 ];then
echo "$username 不是普通用户,请重新输入..."
elif [ "$B" == "$A" ];then
usermod -s /sbin/nologin $username
echo "禁止$username 登录"
fi
vim /root/bin/login.sh
!/bin/bash
read -p "请输入用户名:" username
A=/sbin/nologin
B=grep "^$username" /etc/passwd | cut -d: -f 7
C=grep "^$username" /etc/passwd | cut -d: -f 3
D=grep "^$username" /etc/passwd
if [ $? -ne 0 ];then
echo "系统无此用户..."
elif [ $C -lt 1000 ];then
echo "$username 用户不是普通用户,请重新输入..."
elif [ "$B" == "$A" ];then
usermod -s /bin/bash $username
echo "允许$username 登录"
fi