Check for entries in passwd file:
getent passwd username >/dev/null 2>&1 && echo "user exists" || echo "user does not exist"
id username >/dev/null 2>&1 && echo "user exists" || echo "user does not exist"
awk -F':' '$1 ~ /^username$/ {print $0}' /etc/passwd | grep -w username >/dev/null 2>&1 && echo "user exists" || echo "user does not exist"
- sandip's blog
- Login or register to post comments