TechEarl

Set Password Expiry and Account Aging on Linux (chage)

Set maximum password age, warning days, and an account expiry date with chage, and read the current aging with chage -l. The full password-lifecycle reference.

Ishan Karunaratne⏱️ 3 min readUpdated
Share thisCopied
Set password maximum age, warning period, and account expiry date on Linux with chage, and read current aging with chage -l.

chage (change age) controls the whole password lifecycle: how often it must change, how much warning the user gets, and when the account itself expires. Read the current state with -l, no root needed for your own account:

bash
chage -l deploy

Setting aging is a root task:

Root terminal showing chage -l for a user, then setting maximum age 90, warning 7, and an expiry date with chage -M 90 -W 7 -E, and the updated aging fields.
chage -M sets the maximum age, -W the warning window, and -E the account expiry date.

The fields that matter

bash
sudo chage -M 90 deploy            # password must change every 90 days
sudo chage -m 1 deploy             # at most one change per day (minimum age)
sudo chage -W 7 deploy             # warn 7 days before expiry
sudo chage -I 14 deploy            # 14 days after expiry, lock the account (inactivity)
sudo chage -E 2026-12-31 deploy    # the whole account expires on this date

You can set several at once: sudo chage -M 90 -W 7 -I 14 deploy. All of this lives in /etc/shadow; chage is just the safe editor for it.

Password expiry vs account expiry

The distinction that trips people up:

  • -M (max age) expires the password. The user is forced to set a new one, then carries on. It is a hygiene control.
  • -E (account expiry) expires the account. On that date the user can no longer log in by any method, including SSH keys. It is an access control.

That makes -E the clean way to offboard a contractor on a known end date, or to lock an account immediately (chage -E 0). See lock and unlock a user account.

Set the policy for new users

chage changes one existing user. To set the default for accounts created from then on, edit /etc/login.defs (PASS_MAX_DAYS, PASS_MIN_DAYS, PASS_WARN_AGE). Existing users are unaffected; apply chage to them individually or in a loop.

FAQ

See also

Sources

Authoritative references this article was fact-checked against.

TagsLinuxchagePasswordAccount AgingSecurity

Found this useful? Pass it on.

Copied

Ishan Karunaratne

Tech Architect · Software Engineer · AI/DevOps

Tech architect and software engineer with 20+ years building software, Linux systems, and DevOps infrastructure, and lately working AI into the stack. Currently Chief Technology Officer at a healthcare tech startup, which is where most of these field notes come from.

Keep reading

Related posts