To make a Linux account password never expire, change the account’s password-aging settings. This prevents an age-based forced password change; it does not disable the password, unlock an account, or override rules imposed by a central identity service. You need an administrator account or root access and the username of the local account you intend to change.
What You’ll Need
- A Linux terminal and permission to run commands with
sudo, or access to a root shell. - The exact username of the account. Confirm it before changing settings, especially on a shared or remote system.
- The
chageandpasswdutilities, commonly provided by Linux account-management tools.
Step-by-Step
- Open a terminal and identify the account. If you are changing your own account, check the username with
whoami. To change another local account, use its login name as listed on the system. Do not use a display name or email address unless that is actually the Linux login name. - Check the current password-aging settings. Run
sudo chage -l username, replacingusernamewith the account’s login name. Review the displayed dates and maximum number of days between password changes. If you are already root, omitsudo. The command may report that the password expires on a particular date, or that it never expires. - Set the maximum password age to unlimited. Run
sudo chage -M -1 username. The capital-Msets the maximum number of days before a password must be changed;-1means no maximum age. Enter your own administrator password if prompted. This command changes the aging policy for the specified account; it does not set or reveal the account’s password. - Remove any password-expiration warning period. To avoid warnings tied to a password-expiration date, run
sudo chage -W 0 username. With no maximum age, there is no age-based expiration date for the warning to precede. This setting does not turn off other login warnings or system notices. - Check account expiration separately. Run
sudo chage -E -1 usernameonly if the account itself should also have no expiration date. Password expiration and account expiration are different: an account can be set to expire even when its password does not. Do not run this command if the account is deliberately scheduled to expire, such as a temporary account. - Verify the result. Run
sudo chage -l usernameagain. Confirm that the maximum number of days between password changes is reported as-1or otherwise as never, and check the account expiration field separately if you changed it. The wording varies between Linux distributions. - For your own account, use the username explicitly. You can also run
sudo chage -M -1 "$(whoami)"to apply the change to the account that launched the command. The explicit username form is easier to review before pressing Enter and is safer when administering another user.
On systems where you manage multiple accounts, repeat the checks and change for each intended local user. Avoid applying broad edits to account files or running a command over every account: system and service accounts have different purposes and should not be changed casually.
Common Mistakes
- Confusing password expiration with account expiration.
chage -M -1prevents password aging from forcing a change.chage -E -1removes an account expiration date. Decide which policy you mean; changing one does not necessarily change the other. - Using the wrong username. A misspelled or incorrect name can produce an error or affect another account. Check the name with
whoamior an administrator’s account list before making changes. - Forgetting administrator privileges. Changing another user’s aging settings usually requires root privileges. Use
sudowhere available, or run the command from a root shell. The target user’s password is not a substitute for administrator authorization. - Assuming the change applies everywhere. The command affects the local account database. Accounts authenticated through LDAP, Active Directory, a cloud identity provider, or another central service may have password rules managed elsewhere.
- Expecting this to change the password. These commands alter aging and expiration fields, not the password itself. To change an actual password, use the system’s approved password-change process.
Tips
- Record the account name and original settings before changing a managed system, so you can restore the intended policy if needed.
- Use
chage -lboth before and after the change. Verification is more reliable than assuming a command succeeded because it returned to the prompt. - For an interactive alternative, run
sudo chage username. The prompts let you edit aging fields; enter-1for the maximum number of days to disable password-age expiration. Review each prompt carefully before accepting changes. - Keep other controls in place. A non-expiring password does not prevent account lockout, disable multifactor authentication, or make a weak or exposed password safe. Follow the organization’s security policy for long-lived credentials.
- On a system using centrally managed identities, ask the identity administrator to check the relevant policy rather than editing local files. Local changes may have no effect or may be overwritten.
Troubleshooting
chage: command not found: The utility may not be installed or may not be available in the command search path. Check your distribution’s package manager or system documentation for its account-management tools. Do not edit password-aging files directly unless you understand the format and have a verified backup.
Permission denied: Rerun the command with sudo if your account is authorized, or ask a system administrator. On a managed computer, local administrator rights may be intentionally restricted.
The command says the user does not exist: Check the spelling and whether the account is local. A centrally managed user may not appear in the local account database in the way chage expects. Use the organization’s identity-management process for that account.
The report still shows an expiration date: Read the separate fields carefully. A password-aging date and an account-expiration date are not the same. Re-run sudo chage -l username and confirm that the maximum password age is unlimited. If the account itself should not expire, and policy permits, set that field with sudo chage -E -1 username.
The setting changes back: A scheduled configuration-management job, directory policy, or identity provider may be restoring the previous value. Check with the administrator responsible for the system instead of repeatedly overriding the policy.
Frequently Asked Questions
Does chage -M -1 make a password permanent?
It removes the local maximum-age requirement. The password can still be changed by an administrator or user, and other authentication policies may apply.
Will this unlock a locked Linux account?
No. Password aging and account lockout are separate. Investigate the lockout state and follow the system’s approved account-recovery procedure.
Can I make only my own password never expire?
Yes, if you have administrator permission. Use sudo chage -M -1 "$(whoami)", then verify with sudo chage -l "$(whoami)".
Does this work on every Linux distribution?chage is common on Linux systems using standard local account tools, but it may be absent or irrelevant on some systems. Central account policies can also take precedence.
Does a never-expiring password improve security?
Not by itself. It avoids forced age-based changes but means the password will not expire due to local age settings. Use a strong, unique credential and follow applicable security policy.
How do I undo the change?
Set a finite maximum age with sudo chage -M days username, replacing days with the policy-approved number. Check the system’s policy first; also restore any account-expiration setting you changed if appropriate.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- Fix Apps Not Downloading From Play Store
- Secure a Samsung Galaxy After a Zero-Day Disclosure
- What to Check Before Installing Linux Alongside Windows
- Fix OEM Activation Error 0xc004c060 in Windows 10
- Why Does My App Run One Query for the List and One per Item?
- Fix Google Chrome Has Stopped Working