Welcome to Nik Maslov`s blog
« Nokia 5530 issues with Media LibraryZones related commands »

When user has last changed his password in Solaris

Permalink 12/24/09 19:03, by Nik Maslov, Categories: UNIX , Tags: password, perl, shadow, solaris

Title says it all.  Since, the date of last change of password is in /etc/shadow:

 

root:x:14602::::::

That means, that root has last changed his password 14602 days after beginning of unix epoch, i.e. 1 Jan 1970.

But we need to convert this into normal date, and almost all converters think, that this number is in seconds, not days. To do this, this perl script will be handy (thanks to someone, I found this on inet):

 

#!/usr/bin/perl

# Output date format is YYYY-MM-DD

open( S, "/etc/shadow" );

while( <S> )

{

($user,$lastchg) = (split /:/)[0,2];

@t = localtime( $lastchg*86400 );

printf "User %-8s last changed password %0.4d-%0.2d-%0.2d (%5d)\n",

$user, $t[5]+1900, $t[4]+1, $t[3], $lastchg;

}

close( S );

exit 0;

 

Handy instrument indeed!

3 comments »

3 comments

Comment from: UGGS UK [Visitor] · http://www.ukbootsoutlet.com
good article
07/19/10 @ 11:32
UGG Mayfaire Boots 5116 Sand
08/31/10 @ 12:03
Comment from: MBT Baridi Silver Shoes For Women [Visitor] · http://www.mbtpanda.com/mbt-womens-shoes-mbt-baridi-c-5_30.html
MBT Baridi Silver Shoes For Women
08/31/10 @ 12:03

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)

Search

XML Feeds

StatCounter

blogging software