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

Software Systems Architect · Senior Software Engineer · Engineering Leadership

Software systems architect and senior software engineer with more than two decades designing, building, and running production software, Linux systems, and DevOps infrastructure, and lately working AI into the stack. Now a CTO, though what I write here is drawn from the full arc of that work, across architecture, engineering, and operations, not any single job.

Keep reading

Related posts

nvtop gpu monitoring on Linux: an htop-style ncurses viewer for NVIDIA, AMD, and Intel GPUs showing live utilization, VRAM, temperature, and a sortable per-process list. Install, key bindings, and -d delay flag.

nvtop: Monitor NVIDIA, AMD, and Intel GPUs on Linux

nvtop is an htop-style GPU monitor for Linux. One install (sudo apt install nvtop), one command, and you get live per-GPU utilization, memory, temperature, and a sortable per-process list across NVIDIA, AMD, and Intel cards.