back       next

Check for entries in passwd file

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"

Post new comment

  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.