Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I list all locked users in Linux?

usermod -L user_name

This command locks a particular user. Does Linux have any command that lists locked user?

share|improve this question
add comment

2 Answers

up vote 7 down vote accepted

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.

share|improve this answer
    
And of course this works only if user data is local, and not in some kind of a database (LDAP, etc.). But I suppose this is what the OP wanted. –  haimg Dec 18 '11 at 16:32
    
@haimg Yes. If you want to edit my question to include that information, feel free. –  wizlog Dec 18 '11 at 16:36
add comment
sudo awk '/!\*/' /etc/shadow | cut -d : -f1

Another way for local users.

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.