LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Terminal Command to find out expiry date on user accounts (http://www.linuxquestions.org/questions/linux-newbie-8/terminal-command-to-find-out-expiry-date-on-user-accounts-624805/)

Caighil 02-29-2008 01:50 PM

Terminal Command to find out expiry date on user accounts
 
Hey,
I am a student writing their first bash script. In it we need to make expiry dates for users to expire in one year after creation. I think i did it. Is there a terminal command to see the expiry dates on user accounts?

Thanks in advance

Kyle-

rayfordj 02-29-2008 03:19 PM

Code:

chage -l <username>
should show you information regarding password expirations, min/max days between password changes, ... so you can see if your script is working correctly or not.

Caighil 02-29-2008 03:38 PM

Thanks a lot.... thot i tried that, gues snot.. Your the best!!

bsdunix 02-29-2008 04:47 PM

Here's a quick script based on chage. Replace the 1000 in test for what ever is the beginning user account UID on your system.
Code:

#!/bin/sh

while read inputline
do
        NAME="$(echo $inputline | cut -d: -f1)"
        ID="$(echo $inputline | cut -d: -f3)"
        if [ $ID -ge 1000 ]; then
        echo -n "User: " $NAME " => " ; chage -l $NAME | grep "Account Expires"
        fi
done < /etc/passwd



All times are GMT -5. The time now is 03:43 AM.