I want to create a script to check whether a user exists. I am using the logic below:
# getent passwd test > /dev/null 2&>1 # echo $? 0 # getent pa
Script to Check whether Linux user exists or not
#! /bin/bash USER_NAME=bakul cat /etc/passwd | grep ${USER_NAME} >/dev/null 2>&1 if [ $? -eq 0 ] ; then echo "User Exists" else echo "User Not Found" fi