← Full reference

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

Optionshadow fieldWhat it sets
-l—show the current settings
-i—with -l: dates as YYYY-MM-DD instead of Oct 13, 2026
-M days5maximum password lifetime; after it the password must be changed. -M -1 — remove the limit
-m days4minimum days between password changes; 0 — can be changed any time
-W days6how many days before the password expires to warn at login
-I days7how many days after the password expires you can still log in (by changing the password); after that, login is blocked. -I -1 — remove
-E date8date from which the whole account is disabled. -E -1 — no expiry, -E 0 — disable immediately
-d date3date 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
#FieldExampleMeaning
1namealice
2password hash$y$…! or * — no password set or locked
3last change20739days since 1970-01-01; 0 — change at login; empty — aging is off
4minimum7-m
5maximum90-M; 99999 — effectively never
6warning14-W
7inactivity5-I
8account expiry20849-E, day number
9reservedunused

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-45 silently becomes 2027-02-14, 2026-02-30 becomes 2026-03-02. Always check the result with chage -l -i. The 31.01.2027 format is at least rejected.
  • -E and -M are different things. -M limits the password lifetime (the user is asked to change it), -E disables the whole account, regardless of the password.
  • The limits apply to su from root too. After -E in the past, su alice prints "Your account has expired"; after -d 0 it demands a new password. SSH key login also checks the account expiry.
  • -E 0 is 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_AGE in /etc/login.defs. Editing that file doesn't change existing users.
  • passwd -S alice shows the same settings on one line; there -1 means "not set".

See also

useradd · su · getent · date · id