2 ways to check user password expiration date in Linux

You might want to check if users have changed their password or not. Since you can’t extract password policy easily, a simple way is to look at user attributes and search for new passwords. In this guide, we will cover these areas.

How can I see user password in Linux?

To see the user password in Linux, you need to use the passwd command.

passwd [ -s ] [ -l | -u ] [ -f ] username

The above command will print the user password on stdout.

Passwords are normally stored in /etc/shadow file. To view shadowed passwords, run:

grep “^$USER:” /etc/shadow

How do you check if password is expired in Linux?

1. Checking Password Expiration Date with chage Command

You can also use the chage command to check the password expiration date. It takes the following syntax:

sudo chage -l user_name

For example, let’s see the password expiration date for “paul” user account:

$ sudo chage -l paul

Last password change : none

Minimum number of days between password changes : 0

Maximum number of days between password changes : 999999999999

Password expiration warning period : 1 day

Password expiration warning period in days : 14

2. Checking Password Expiration Date with passwd Command

The passwd command is used to change a user’s password on Linux. It is also used to set the expiration date for the password.

The following example will show you how to check the expiration date for a user’s password:

$ sudo passwd -d alice

Changing password for user alice.

New UNIX password: **********

Retype new UNIX password: **********

passwd: all authentication tokens updated successfully.

How do I change my password expiry in Linux?

You can change your password by running the following command:

$ passwd

If you want to change the expiration date of your password, use the following command:

$ sudo passwd -d 0 myusername

What is password aging in Linux?

Password aging is a security feature in Linux which enables you to password-lock your user accounts after a certain time period. This can be done in two ways:

1)By default, system administrators create a new user account and assign a password to it. This password is the key used to gain access to the system. However, anyone who knows this password can log into the system.

2)If you enable password aging, you can set a time limit for how long an account remains unlocked before it must be changed again. By doing so, you can ensure that no one uses an old or easily guessed password to gain access to your system.

How to set a user’s password to never expire in Linux?

To set a password to never expire, you can use the chage command. This command is used to modify the user account password and other account attributes. chage stands for change age. The syntax of this command is as follows:


The options are as follows:

-l: To set the maximum life of the password in days, weeks or months (the default is 90 days)

-E: To enable enforcement of password aging policies for this user’s login.

-I: To disable enforcement of password aging policies for this user’s login.


Leave a Reply

Your email address will not be published. Required fields are marked *