Skip to content

Instantly share code, notes, and snippets.

@fduran
Created March 6, 2012 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fduran/1989361 to your computer and use it in GitHub Desktop.
Save fduran/1989361 to your computer and use it in GitHub Desktop.
Find Linux users that can log in with password
# www.fduran.com
# Check which Linux users could log in with password, see "man shadow" for the second field in the /etc/shadow file:
# "If the password field contains some string that is not a valid result of crypt(3), for instance ! or *, the user will not be able to use a unix password to log in (but the user may log in the system by other means).
# this awk one-liner will find users that have common used * or ! in the password field or field starts with ! (locked account). It's possible that still found user cannot log in due to other non-crypt character in the field
awk -F: '$2 != "*" && $2 !~ /^!/ { print $1, " can log in" }' /etc/shadow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment