LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Other *NIX (http://www.linuxquestions.org/questions/other-%2Anix-55/)
-   -   how to check the password expiry date of a user? (http://www.linuxquestions.org/questions/other-%2Anix-55/how-to-check-the-password-expiry-date-of-a-user-646846/)

binary_0011 06-04-2008 01:01 AM

how to check the password expiry date of a user?
 
i want to check when is the password expiry date of a particular user, how can I do that in HP UX 11?

I don't need a script, i just want to check the status of some users occasionally.

Thanks.

jschiwal 06-04-2008 02:37 AM

If your system uses the /etc/shadow file, then that is where the information is contained, rather than /etc/passwd.

To read an record in many system files, you can use the "getent" command. However the shadow file is readable only by root.
Code:

NAME
      shadow - encrypted password file

DESCRIPTION
      shadow  contains  the  encrypted password information for user's accounts and optional the password
      aging information. Included is

            Login name

            Encrypted password

            Days since Jan 1, 1970 that password was last changed

            Days before password may be changed

            Days after which password must be changed

            Days before password is to expire that user is warned

            Days after password expires that account is disabled

You can use awk to calculate the expiration date, field 3 + field 5. This is the date since 1970 so you need to use the "date" command to make this human readable. ( see man shadow for details ) Also check the man/info page for your version of awk to see if it has a function that can convert a SYSTIME entry to a human readable form. If so, calculating "24*60*60*($3+$5)" in awk will give the SYSTIME version of the expiration date.

There may also be a "chage" command. As root you can enter "chage -l <username>". If you are a regular user, a password may be necessary. If you have the chage command, then this would be the handiest way to get a readily human readable form of this information.


If neither of these work, you need to look into how user account information is stored. Do you use NIS or LDAP? Do you use PAM and pam_userdb.so? The /etc/nsswitch file may contain some useful pointers. For example, look at the "users:" line and the "shadow:" line.


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