How can I list all locked users in Linux?

passwd -S -a | grep LK | cut -d " " -f1 and/or passwd -S -a |awk '/LK/{print $1}' should work.

(in case your interested)

Both of these illustrations demonstrate a very common technique that is used throughout Unix/Linux: what I'll call command piping.

In these examples, the output of one command (such as ls is "piped to" another command, which effectively filters its input and sends it down the line.

Refer to LinuxQuestions.org for more information.


sudo awk '/!\*/' /etc/shadow | cut -d : -f1

Another way for local users.