Change password – expiration in linux

If you just want to change a password you can use the passwd command.

If you want to set a time-limit after which the user has to change his passwort you can do that with this command:

sudo chage <username>


sudo passwd -x 90 <username> ( 90 stands for 90 days )

If you want to see the password-settings for a user you can use this command:

sudo chage -l <username>

Example of the /etc/shadow file:


There are several values, which are seperated by a „:“. The first value, „bc“, is the username. The second is a hash value of the password and some other userdata.(Note: If two users have the same password, the hashes aren’t equal!

The third is the expiration date of the passwort. It gets computed by:

January 1st, 1970 + this value in days = expiration day

The fourth value is the number of days between two password changes. „0“ stands for:“not specified“

The fifth value is the number of days, the password is valid.

The sixt value is the number of days, the user should be warned before the password expires.

The seventh value is the number of days between the expiration of the password and the lock of the user account.

The last value is the expiration of the user account in days since the 1st of January in 1970.

You can edit the information as root, the tools mentioned above are only a frontend.

More information is available at: