判断linux的用户状态

                    判断linux的用户状态

目的:判断linux系统中某一用户的 是否存在,若存在,则输出该用户的家目录,使用的内核和密码状态。

 具体的代码:

#!/bin/bash
read -p "please input one account:" ACCOUNT
if grep "^$ACCOUNT\>" /etc/passwd &>/dev/null;then
HOMEDIR=`grep "^$ACCOUNT\>" /etc/passwd |cut -d: -f 6`
SHELL=`grep "^$ACCOUNT\>" /etc/passwd |cut -d: -f 7`
echo "this user $ACCOUNT is exist"
echo "this user homdir  is $HOMEDIR"
echo "this user shell is $SHELL"
/usr/bin/passwd -S $ACCOUNT &>/tmp/state

if grep -i "lock"  /TMP/STATE;then
    echo "lock"
elif grep -i "empty" /tmp/state;then
    echo "empty"
elif grep -i "md5" /tmp/state;then
    echo  "encry"
fi
else
echo "this user $ACCOUNT is not exist"
fi

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章