check_user_createdate.sh

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

  在前面这篇文章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
相关文章
|
28天前
|
Shell 应用服务中间件 Linux
已解决:Cannot find ./catalina.sh The file is absent or does not have execute permission This file is ne
已解决:Cannot find ./catalina.sh The file is absent or does not have execute permission This file is ne
11 0
|
8月前
|
存储 关系型数据库 MySQL
The user specified as a definer (‘root‘@‘%‘) does not exist
The user specified as a definer (‘root‘@‘%‘) does not exist
|
关系型数据库 MySQL
The user specified as a definer (‘root‘@‘%‘) does not exist(已解决)
The user specified as a definer (‘root‘@‘%‘) does not exist(已解决)
397 0
The user specified as a definer (‘root‘@‘%‘) does not exist(已解决)
|
XML 分布式计算 Hadoop
hiveserver2连接报错: User: root is not allowed to impersonate anonymous (state=08S01,code=0)
hiveserver2连接报错: User: root is not allowed to impersonate anonymous (state=08S01,code=0)
680 0
|
Linux 虚拟化
安装centos7 报错[FAILED] Failed to start Switch Root. see 'systemctl status initrd-switch-root.service' for details
安装centos7 报错[FAILED] Failed to start Switch Root. see 'systemctl status initrd-switch-root.service' for details
24234 0
|
MySQL 关系型数据库 数据安全/隐私保护