How find user with empty password in Linux?

How find user with empty password in Linux?


This is a shorter and more precise version of AndreKR's answer:

sudo getent shadow | grep '^[^:]*:.\?:' | cut -d: -f1

It has only one call to cut and will find entries of any of the forms below:

foo:!: ...
bar:*: ...
baz:: ...

If you only want truly empty:

sudo getent shadow | grep '^[^:]*::' | cut -d: -f1

If you have GNU grep, you can eliminate cut completely:

sudo getent shadow | grep -Po '^[^:]*(?=:.?:)'

or

sudo getent shadow | grep -Po '^[^:]*(?=::)'

getent shadow | cut -d: -f1-2 | grep ':$' | cut -d: -f1

Encrypted password is the second field in /etc/shadow.

If second field is empty, then password empty:

awk -F":" '($2 == "") {print $1}' /etc/shadow

! and * is invalid password(user can not login):

awk -F":" '($2 == "!" || $2 == "*") {print $1}' /etc/shadow