LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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
 
LinkBack 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
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,361

Rep: Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909
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,695
Blog Entries: 5

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

Rep: Reputation: 953Reputation: 953Reputation: 953Reputation: 953Reputation: 953Reputation: 953Reputation: 953Reputation: 953
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are 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


All times are GMT -5. The time now is 08:28 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration