Linux: Set Password to NEVER Expire

If your Linux user’s password is about to expire, you may see a message as follows on your login screen:

Warning: Your password will expire in X days

In this note i will show how to disable the Linux user’s password expiration from the command line using the chage command.

Cool Tip: How to generate a password hash for /ect/shadow in Linux! Read more →

Set Password to NEVER Expire in Linux

To check a user’s password expiration settings in Linux, use the chage command:

$ chage -l <username>
- sample output -
Last password change					: Sep 30, 2021
Password expires					: Dec 29, 2021
Password inactive					: never
Account expires						: never
Minimum number of days between password change		: 0
Maximum number of days between password change		: 90
Number of days of warning before password expires	: 7

To set the Linux user’s password to never expire in an interactive mode:

$ sudo chage <username>
- sample output -
Changing the aging information for <username>
Enter the new value, or press ENTER for the default

	Minimum Password Age [0]: Enter
	Maximum Password Age [90]: 99999
	Last Password Change (YYYY-MM-DD) [2021-09-30]: Enter
	Password Expiration Warning [7]: Enter
	Password Inactive [-1]: Enter
	Account Expiration Date (YYYY-MM-DD) [-1]: Enter

To turn off the Linux user’s password expiration non-interactively:

$ sudo chage -I -1 -m 0 -M 99999 -E -1 <username>

Ensure that the user’s password expiration settings have changed:

$ chage -l <username>
- sample output -
Last password change					: Sep 30, 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

Cool Tip: Generate a random password from the Linux command line! Read more →

2 Replies to “Linux: Set Password to NEVER Expire”

  1. Excelente

  2. Clear and crispy !

Leave a Reply