check_user_createdate.sh

  在前面这篇文章Linux如何找出用户的创建时间里面讨论了查看用户创建时间的方法,后面自己尝试弄了一个脚本来检查所有用户创建时间脚本,当然更合理的应该叫检查所有用户的密码修改时间比较准确(因为这种方法有条件限制),期间和夕照讨论了一下如何用shell脚本实现,获益良多。下面是整理过后的脚本。

#! /bin/bash
 
echo 'this is not the standard method the check the user create date
      if the user modified the password after the user created,
      the output result will not correct, please noted!';
 
userpwdfile=/etc/shadow
 
 
for line in `cat $userpwdfile`:
  do
      days=`echo $line|awk -F ':' '{print $3}'`
 
      username=`echo $line | awk -F ':' '{print $1}'`
 
      pwdchangetime=`date -d "1970-01-01 $days days" "+%Y/%m/%d"`
 
      echo $username $pwdchangetime
  done
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值