判断linux的用户状态

                    判断linux的用户状态linux

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

 具体的代码:bash

#!/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/stateide

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"
fithis

相关文章
相关标签/搜索