Linux: Set a users password to “never” expire.
In this article i will show you how to set a users password to never expire, to do this we will use the chage command, this command can be…
In this article i will show you how to set a users password to never expire, to do this we will use the chage command, this command can be used interactively and non-interactively and in both cases must run with sudo or as root user
How to see the password expiration status of a user$ chage -l <username>
- sample output -
Last password change : May 29, 2022
Password expires : Jul 29, 2023
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
How to set the password expiration date for a user (interactively)$ 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
-1 as an option means never, this way we can set the “Account Expiration Date” to never
How to set the password expiration date for a user (as an one-liner)sudo chage -I -1 -m 0 -M 99999 -E -1 <username>
To ensure changes enter$ chage -l <username>
- sample output -
Last password change : May 29, 2022
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
Note that the above one-liner will change many other options as well like password expire setting, account expire etc.
I hope you found this short article interesting :)