LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-13-2011, 04:29 AM   #1
deepak_message
Member
 
Registered: Oct 2007
Posts: 172

Rep: Reputation: 17
How to check user is locked or unlocked by command


Hi,

I need to check that user is lock or unlock by the command.
please help.
 
Old 09-13-2011, 04:37 AM   #2
jv2112
Member
 
Registered: Jan 2009
Location: New England
Distribution: Arch Linux
Posts: 719

Rep: Reputation: 103Reputation: 103
Please clarify further.
 
Old 09-14-2011, 01:18 AM   #3
deepak_message
Member
 
Registered: Oct 2007
Posts: 172

Original Poster
Rep: Reputation: 17
I am using redhat6.0 , I have lock to some users byt he command (passwd -l <username> or usermod -L <username>), now need to know that how will identify which user has locked.
 
Old 09-14-2011, 01:33 AM   #4
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1296Reputation: 1296Reputation: 1296Reputation: 1296Reputation: 1296Reputation: 1296Reputation: 1296Reputation: 1296Reputation: 1296
Hello,

You'll have to check if RHEL6 has this option (5.6 doesn't). You can use the following to find out the status of user accounts and passwords:
Code:
passwd -Sa
The output description from the man page (Debian):
Quote:
-S, --status
Display account status information. The status information consists of 7 fields. The first field is the user's login name. The second field indicates if
the user account has a locked password (L), has no password (NP), or has a usable password (P). The third field gives the date of the last password
change. The next four fields are the minimum age, maximum age, warning period, and inactivity period for the password. These ages are expressed in days.
In RHEL5.6 the -S option works but only with one user at a time, you'll have to check if you have the -a option available in RHEL6.0.

Kind regards,

Eric
 
1 members found this post helpful.
Old 09-14-2011, 11:35 AM   #5
zQUEz
Member
 
Registered: Jun 2007
Distribution: Fedora, RHEL, Centos
Posts: 294

Rep: Reputation: 54
the following works as noted:
For RHEL5
Code:
for i in `cat /etc/passwd |cut -d: -f1`; do passwd -S $i; done
For RHEL4
Code:
for i in `cat /etc/passwd |cut -d: -f1`; do echo "$i `passwd -S $i`"; done
 
Old 11-12-2014, 12:17 PM   #6
aswani5858
LQ Newbie
 
Registered: Aug 2014
Location: Bengaluru
Distribution: RedHat
Posts: 12

Rep: Reputation: Disabled
Smile

from man page:
-S This will output a short information about the status of the password for a given account. Available to root user only.

eg:
kruthiva PS 2014-11-05 7 90 10 14 (Password set, DES crypt.)

LK - password locked
NP - no password
PS - password set

Last edited by aswani5858; 11-12-2014 at 12:23 PM.
 
Old 11-12-2014, 02:44 PM   #7
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 21,828

Rep: Reputation: 5783Reputation: 5783Reputation: 5783Reputation: 5783Reputation: 5783Reputation: 5783Reputation: 5783Reputation: 5783Reputation: 5783Reputation: 5783Reputation: 5783
Quote:
Originally Posted by aswani5858 View Post
from man page:
-S This will output a short information about the status of the password for a given account. Available to root user only.

eg:
kruthiva PS 2014-11-05 7 90 10 14 (Password set, DES crypt.)

LK - password locked
NP - no password
PS - password set
Yes, the "-S" option was mentioned previously...and this thread had been closed for THREE YEARS....
 
Old 11-16-2014, 02:56 AM   #8
aswani5858
LQ Newbie
 
Registered: Aug 2014
Location: Bengaluru
Distribution: RedHat
Posts: 12

Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
Yes, the "-S" option was mentioned previously...and this thread had been closed for THREE YEARS....
Okay, sorry. Thanks.
 
  


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



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
Locked-down user account lukeprog Ubuntu 6 01-28-2006 11:21 AM
Threads that are locked and have no replies should be unlocked and replied to t3gah LQ Suggestions & Feedback 13 04-13-2005 08:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:47 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration