chage
Password and account expiry — chage -l, -M, -m, -W, -I, -E, -d 0 and the /etc/shadow fields
chage (change age) manages password "age": after how many days it must be changed, how many days in advance to warn, when the account stops working altogether. All these values live in /etc/shadow; chage just edits the right fields. Only root can change them; a regular user can only view their own settings with chage -l.
Syntax
chage -l user # view
chage [options] user # change
With no options (other than the name) chage asks for every value interactively.
Options
| Option | shadow field | What it sets |
|---|---|---|
-l | — | show the current settings |
-i | — | with -l: dates as YYYY-MM-DD instead of Oct 13, 2026 |
-M days | 5 | maximum password lifetime; after it the password must be changed. -M -1 — remove the limit |
-m days | 4 | minimum days between password changes; 0 — can be changed any time |
-W days | 6 | how many days before the password expires to warn at login |
-I days | 7 | how many days after the password expires you can still log in (by changing the password); after that, login is blocked. -I -1 — remove |
-E date | 8 | date from which the whole account is disabled. -E -1 — no expiry, -E 0 — disable immediately |
-d date | 3 | date of the last password change; -d 0 — force a password change at the next login |
-R directory | — | work with /etc/shadow inside a different root (chroot) |
Write dates as YYYY-MM-DD; a plain number is treated as a day number counted from January 1, 1970.
/etc/shadow fields
alice:$y$j9T$…:20739:7:90:14:5:20849:
1 2 3 4 5 6 7 8 9
| # | Field | Example | Meaning |
|---|---|---|---|
| 1 | name | alice | |
| 2 | password hash | $y$… | ! or * — no password set or locked |
| 3 | last change | 20739 | days since 1970-01-01; 0 — change at login; empty — aging is off |
| 4 | minimum | 7 | -m |
| 5 | maximum | 90 | -M; 99999 — effectively never |
| 6 | warning | 14 | -W |
| 7 | inactivity | 5 | -I |
| 8 | account expiry | 20849 | -E, day number |
| 9 | reserved | unused |
To convert a day number to a date: date -d @$((20849*86400)) +%F.
chage -l output
Last password change : Oct 13, 2026
Password expires : Jan 11, 2027
Password inactive : Jan 16, 2027
Account expires : Jan 31, 2027
Minimum number of days between password change : 7
Maximum number of days between password change : 90
Number of days of warning before password expires: 14
Password expires = last change + maximum, Password inactive = expiry + -I. After -d 0 the first three lines say password must be changed.
Examples
# view the settings, dates in ISO format
chage -l -i alice
# policy: change every 90 days, no more than once a week, warn 14 days ahead
chage -M 90 -m 7 -W 14 alice
# temporary employee: the account works until the end of the month
chage -E 2027-01-31 alice
# set a temporary password and force a change at login
echo 'alice:Temp-Passw0rd' | chpasswd
chage -d 0 alice
# block login right now, then restore it
chage -E 0 alice
chage -E -1 alice
# remove all limits
chage -M -1 -I -1 -E -1 alice
# same when creating a user: -e — account expiry, -f — inactivity
useradd -m -e 2027-12-31 -f 10 bob
# the shadow fields directly
getent shadow alice
Pitfalls
- An invalid date doesn't cause an error.
chage -E 2026-13-45silently becomes2027-02-14,2026-02-30becomes2026-03-02. Always check the result withchage -l -i. The31.01.2027format is at least rejected. -Eand-Mare different things.-Mlimits the password lifetime (the user is asked to change it),-Edisables the whole account, regardless of the password.- The limits apply to
sufrom root too. After-Ein the past,su aliceprints "Your account has expired"; after-d 0it demands a new password. SSH key login also checks the account expiry. -E 0is January 1, 1970, i.e. "already expired", not "no expiry". No expiry is-E -1.- Defaults for new users come from
PASS_MAX_DAYS,PASS_MIN_DAYS,PASS_WARN_AGEin/etc/login.defs. Editing that file doesn't change existing users. passwd -S aliceshows the same settings on one line; there-1means "not set".