#! /bin/sh # # Script to report (on screen, if no redirection) on expiration date of # the password of each user. Skips the first 18 accounts listed in # /etc/passwd as they are not for real users. Adjust this number to # fit the passwd file on your system. tmpfile="/tmp/checkexp.$$" if [ `whoami` != "root" ] then echo "Only root can run this script" exit 1 fi cat /etc/passwd | cut -d ':' -f1 > "$tmpfile" sync sleep 1 count=0 while read id do if [ "$count" = "18" ] then echo -ne "$id \t" chage -l $id | grep "Password Expires:" else # skip the first several accounts count=`expr $count + 1` fi done < "$tmpfile" sync sleep 1 rm $tmpfile exit 0