歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> 學習Linux >> check_user_createdate.sh,createstackuser.sh

check_user_createdate.sh,createstackuser.sh

日期:2017/3/6 9:36:02   编辑:學習Linux

check_user_createdate.sh,createstackuser.sh


check_user_createdate.sh,createstackuser.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

http://xxxxxx/Linuxjc/1136967.html TechArticle

Copyright © Linux教程網 All Rights Reserved