I want to check wether user exist in server or not uisng shell script?
can any one help me regarding this
This script will tell you if a user account exists on the system, just pass the user name you want to check as an argument to the script like
#!/bin/bash cat /etc/passwd | grep ^$1 >/dev/null if [ $? == 0 ]; then echo "User $1 exists." exit 0 else echo "User $1 does not exist." exit 1 fi
uuoc (useless use of cat)
uuot (useless use of test)
if grep -q ^"$1" /etc/passwd then echo "user $1 exists" else echo "user $1 does not exist" exit 1 fi
Here i have 1 more arised. my linux box is not a stand alone. This is connected in intrenet my used id is also a domain account.
How to check the domain account.
What type of domain account?
I'd rather use the id(1) command :
if id -u $1 then echo "user $1 exists" else echo "user $1 does not exist" exit 1 fi