| « Nokia 5530 issues with Media Library | Zones related commands » |
When user has last changed his password in 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!