DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

hemanlinux
hemanlinux

Posted on

how to change the account password expiration date in Linux

Question:
I am confused about the password expiration date in Linux. Looks like chage command -e changes the account expiration date not the password expiration date.

Two things are totally different. I can not find any command that can be used to change the password expiration date.

All Linux commands change the user expiration date. is there any way to do this? Thanks a lot.

Answer:

Use chage -M. For example, to set 90 days as the maximum before password expiry enter sudo chage -M 90 .

EDIT: To set an exact expiration date you need to figure out how many days that are between the Last password change date (see chage -l) and your desired password expiration date and then use that number in chage -M.

Reference: https://www.howtouselinux.com/post/change-user-password-expiration-date-in-linux

Top comments (0)

Become a Moderator Do you want us to help make DEV a better place?

Fill out this survey and help us by becoming a tag moderator here at DEV.