Linux Check User Password Expiration Date and Time

‮h‬ttps://www.lautturi.com
Linux Check User Password Expiration Date and Time

On a Linux system, you can use the chage command to check the password expiration date and time for a user. The chage command is used to change the password aging information for a user, including the password expiration date and time.

To check the password expiration date and time for a user, you can use the -l option, followed by the username. For example, to check the password expiration date and time for the user user1, you can run:

chage -l user1

This will show the password aging information for the user, including the last password change date, the minimum and maximum password age, and the password expiration date. If the password expiration date is not set, it will be displayed as never.

Here is an example of the output of the chage command:

Last password change                                    : Oct 16, 2021
Password expires                                       : never
Password inactive                                      : never
Account expires                                        : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 99999
Number of days of warning before password expires       : 7

Keep in mind that the password aging information is stored in the /etc/shadow file, which is only readable by the root user. You will need to have superuser privileges in order to use the chage command.

If you want to change the password expiration date and time for a user, you can use the -M option to set the maximum number of days between password changes, and the -E option to set the password expiration date. For example, to set the password expiration date for the user user1 to December 31, 2022, you can run:

chage -E 2022-12-31 user1

If you are not familiar with the chage command or password aging on Linux, you may want to consult the chage documentation or a reference guide for more information.

Created Time:2017-10-29 22:08:52  Author:lautturi