Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How find user with empty password in Linux?

share|improve this question
getent shadow | cut -d: -f1-2 | grep ':$' | cut -d: -f1
share|improve this answer

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 '^[^:]*(?=:.?:)'


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

Their entry in /etc/shadow/ will have no password-hash in it. You'll need to be logged in as root to be able to see them, though.

share|improve this answer

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
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.