AIX查看用户最近一次密码修改时间

在系统文件/etc/security/passwd中记录有每个用户登陆密码的加密形式,以及上次修改密码的时间,我们以root为例:
root:
password = xxxx
flags =
lastupdate = 1556451521
此处,lastupdate为上次密码修改时间,以epoch time表示。

使用脚本提取lastupdate值
# cat /etc/security/passwd | grep -p root | grep lastupdate | awk '{print $3}'
1556451521
或者:
pwdadm -q root  | grep lastupdate | awk '{print $3}'
或者:
lssec -f /etc/security/passwd -s root -a lastupdate  | awk -F '=' '{print $2}'
转换时间格式
# perl -le 'print scalar localtime 1556451521'
Sun Apr 28 19:38:41 2019
或者:
perl -e 'use POSIX;print ctime(1556451521)'

所以,root用户上次修改密码是在2019年8月28日19:38:41。

猜你喜欢

转载自blog.csdn.net/allway2/article/details/108526513
今日推荐