Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How find user with empty password in Linux?

share|improve this question
add comment

4 Answers

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

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 '^[^:]*(?=::)'
share|improve this answer
add comment

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
add comment

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
add comment

Your Answer

 
discard

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.