LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-13-2009, 04:28 AM   #1
robbiezr
LQ Newbie
 
Registered: Apr 2009
Posts: 2

Rep: Reputation: 0
Smile how to list all locked account in linux?


how to list locked account in linux(redhat)?
I can use the command "passwd -S -username" to list a account who were locked .
who knows how to list all locked accounts with one command.
 
Old 04-13-2009, 06:51 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Code:
passwd -S -a | grep LK | cut -d " " -f1
 
Old 04-13-2009, 07:01 AM   #3
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Code:
passwd -S -a |awk '/LK/{print $1}'
 
Old 04-13-2009, 07:46 AM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
FYI...

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.

As the Perl folks like to say, "there's more than one way to do it." Both of these techniques work equally well.
 
Old 04-13-2009, 09:00 PM   #5
robbiezr
LQ Newbie
 
Registered: Apr 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks for replying.
I tried the command below :

Code:
passwd -S -a | grep LK | cut -d " " -f1
Code:
 passwd -S -a |awk '/LK/{print $1}'
but the system warns that "passwd: bad argument -a: unknown option".
I think there is no argument -a in this linux version.

I found that if a user is locked .there is a !! symbol in the row in the file /etc/shadow.

Code:
zr:!!$1$GDBXQuoJ$vnxddvimJCknM1P9HFz0v1:14347:0:99999:7:::
 
Old 10-05-2009, 12:34 PM   #6
brycen
LQ Newbie
 
Registered: Sep 2004
Posts: 7

Rep: Reputation: 0
Lightbulb

Under Debian at least the relevant string is "L" not "LK". So:

Code:
passwd -S -a | grep " L " | cut -d " " -f1
or

Code:
passwd -S -a | cut -d " " -f1-2 | grep "L$"
 
Old 09-19-2012, 12:26 PM   #7
ccrmsc
LQ Newbie
 
Registered: Sep 2012
Location: San Jose, CA
Distribution: Centos / Linux RHEL6
Posts: 4

Rep: Reputation: 0
I know this is an old thread but I came up with this solution for RHEL6.

cat /etc/passwd | cut -d : -f 1 | awk '{ system("passwd -S " $0) }'
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference betwwen : Locked User Account & Disabled User Accounts in Linux ? avklinux Linux - Security 1 02-04-2009 02:30 PM
print user list, showing a locked user account?? royal024 Linux - Newbie 4 10-18-2008 10:57 AM
viewing a locked account tataiermail Linux - General 5 07-11-2007 03:21 AM
How to get a list of users with their password status (expired, account locked...)? ricky_ds Linux - General 6 02-28-2005 09:53 AM
locked pop3-account jonas_the_joker Linux - General 1 10-17-2003 07:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration