chage Command: Checking Password Expiry Dates and Using the -M, -E, and -d Options
The chage command checks and changes the password validity period and the account expiry date of a Linux account. Comparing the chage -l output with the default value files on AlmaLinux 9 and Debian 12 servers showed that the password expiry date is calculated by adding the maximum number of days to the last change date, and that on both servers the default maximum was 99999 days, so passwords were set never to expire.
The output below was produced on an AlmaLinux 9.8 server under the root account and on a Debian 12 server under a regular account. Account names and dates have been replaced with example values.
1️⃣ How to Use the chage Command
The basic form is [chage options username]. The password validity period is stored in /etc/shadow, which only root can read, so options that change values are run as root or with sudo. According to the official manual, only the -l option can be used by a regular account on its own account.
chageUsage: chage [options] LOGIN
Options:
-d, --lastday LAST_DAY set date of last password change to LAST_DAY
-E, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE
-h, --help display this help message and exit
-i, --iso8601 use YYYY-MM-DD when printing dates
-I, --inactive INACTIVE set password inactive after expiration
to INACTIVE
-l, --list show account aging information
-m, --mindays MIN_DAYS set minimum number of days before password
change to MIN_DAYS
-M, --maxdays MAX_DAYS set maximum number of days before password
change to MAX_DAYS
-R, --root CHROOT_DIR directory to chroot into
-W, --warndays WARN_DAYS set expiration warning days to WARN_DAYSRunning it without an account name printed only the usage and ended with exit code 2. According to the exit code table in the official manual, chage ends with 0 on success, 1 without permission, 2 for an invalid option, and 15 when the /etc/shadow file cannot be found.
Options that change values finish without any output on success, so look up the changed values again with chage -l. Several options can be written together on one line.
2️⃣ Checking Password Expiry Information with chage -l
The -l option prints the password validity period and expiry dates of an account in seven lines. One system account was looked up on the AlmaLinux 9.8 server. The account name and dates are example values.
chage -l user1Last password change : Oct 01, 2026
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7The first line is the date the password was last changed. The second line, Password expires, is the password expiry date obtained by adding the maximum number of days to that date; when the maximum is the default 99999, it shows never.
The third line, Password inactive, is the date the account is locked after the password expires, and the fourth line, Account expires, is the account expiry date set separately from the password. The three lines below are the minimum and maximum number of days between password changes and the number of warning days before expiry.
Adding -i changed only the dates to the YYYY-MM-DD form, and the other lines stayed the same.
chage -l -i user1Last password change : 2026-10-01
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7Looking up its own account from a regular account on the Debian 12 server printed the same seven lines as for root.
chage -l webuserLast password change : Jan 20, 2026
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7Looking up another account from the same regular account ended with [chage: Permission denied.], and the message was the same on the AlmaLinux 9.8 server when root looked up another account with the privileges of the nobody account.
chage -l daemonchage: Permission denied.A regular account can look up its own account because of the permissions on the chage program. /usr/bin/chage on the AlmaLinux 9.8 server has an s (setuid) in the owner field, so even when a regular account runs it, it reads /etc/shadow with root privileges. On the Debian 12 server, the group field had an s (setgid) and the shadow group.
stat -c "%A %U %G %n" /etc/shadow /usr/bin/chage---------- root root /etc/shadow
-rwsr-xr-x root root /usr/bin/chageLooking up a nonexistent account ends with an error saying the name is not in /etc/passwd.
chage -l user9chage: user 'user9' does not exist in /etc/passwd3️⃣ chage Options
Print the list of options with chage --help. In shadow-utils 4.9 on the AlmaLinux 9.8 server, -l is the lookup option, -i, -h, and -R are auxiliary options, and the six options -d, -E, -I, -m, -M, and -W change values.
| Option | Copy | Description |
|---|---|---|
| -l, --list | Shows the password validity period and expiry dates | |
| -i, --iso8601 | Prints dates in the YYYY-MM-DD form, together with -l | |
| -d, --lastday | Sets the last password change date; 0 means change at the next login | |
| -E, --expiredate | Sets the account expiry date (YYYY-MM-DD); -1 removes it | |
| -M, --maxdays | Maximum number of days the password can be used; -1 turns off the check | |
| -W, --warndays | Number of days of warning before expiry |
| Option | Copy | Description |
|---|---|---|
| -I, --inactive | Number of days after the password expires until the account is locked; -1 removes it | |
| -m, --mindays | Minimum number of days between password changes; 0 means no limit | |
| -R, --root | Applies to the configuration files in another root directory | |
| -h, --help | Prints help |
Date values are written in the YYYY-MM-DD form or as the number of days since January 1, 1970.
Writing only an account name without options switches to interactive mode, which asks for each value in turn and shows the current value in square brackets. Type a new value, or press only Enter for fields to keep as they are.
chage user1Changing the aging information for user1
Enter the new value, or press ENTER for the default
Minimum Password Age [0]:
Maximum Password Age [99999]: 90
Last Password Change (YYYY-MM-DD) [2026-10-01]:
Password Expiration Warning [7]: 14
Password Inactive [-1]:
Account Expiration Date (YYYY-MM-DD) [-1]: The example above is input that changed only the maximum number of days and the warning days and skipped the rest with Enter.
🔲 chage Command Simulator
In the simulator below, you can look up values with chage -l and try changing the password validity period with the -M, -E, and -d options and with interactive input without options.
4️⃣ Practical chage Command Examples
🔲 Expiry Warnings and Changing the Password at First Login
The devuser account created with useradd was given a maximum of 90 days and 14 warning days, and the messages for each setting were checked by logging in to devuser with su from the regular account alice.
The last change date was set to 80 days ago to create a state where the password expires in ten days. After the password was entered, the remaining number of days appeared as a warning, and the login went ahead as usual.
~]# chage -d $(date -d '-80 days' +%F) devuser
~]# chage -l devuser | head -2
Last password change : Aug 26, 2026
Password expires : Nov 24, 2026
~]# su - alice -c 'su - devuser -c id'
Password:
Warning: your password will expire in 10 days.
uid=1001(devuser) gid=1001(devuser) groups=1001(devuser),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023After -d 0 was set, a message said the administrator required a change, and the current password and the new password were asked for in turn; the command ran only after the new password was entered twice.
~]# chage -d 0 devuser
~]# su - alice -c 'su - devuser -c id'
Password:
You are required to change your password immediately (administrator enforced).
Current password:
New password:
Retype new password:
uid=1001(devuser) gid=1001(devuser) groups=1001(devuser),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023Looking it up after the password was changed showed Last password change back at that day's date, and Password expires recalculated to 90 days from that day.
~]# chage -l devuser | head -3
Last password change : Nov 14, 2026
Password expires : Feb 12, 2027
Password inactive : neverWhen a past date was set as the account expiry date with -E, login was blocked with a message saying the account had expired, even when the password was entered correctly. Removing it with -E -1 brought Account expires back to never.
~]# chage -E 2026-11-01 devuser
~]# su - alice -c 'su - devuser -c id'
Password:
Your account has expired; please contact your system administrator.
su: User account has expired
~]# chage -E -1 devuser
~]# chage -l devuser | grep 'Account expires'
Account expires : never🔲 Common Beginner Mistakes
chage -E ended with exit code 0 and no error even when the date form was wrong. 2026-31-12, with the month and day swapped, was saved as July 12, 2028, and the nonexistent date 2026-12-32 was saved as the next day, January 1, 2027. 20261231, written without hyphens, was read as a number of days since January 1, 1970 and saved as the year 57443.
~]# chage -E '2026-31-12' devuser
~]# chage -l devuser | grep 'Account expires'
Account expires : Jul 12, 2028
~]# chage -E '20261231' devuser
~]# chage -l devuser | grep 'Account expires'
Account expires : May 15, 57443
~]# chage -E '2026-12-32' devuser
~]# chage -l devuser | grep 'Account expires'
Account expires : Jan 01, 2027So after running -E, check the Account expires line right away with chage -l. A value written in year, month, day order, such as 2026-12-31, was saved as it was, as Dec 31, 2026.
Another common mistake is checking whether a setting took effect with su from root. Even when the account had expired because a past date was set with -E, su from root asked for nothing and printed the id result; the expiry message appeared only when switching with su from a regular account.
~]# su - devuser -c id
uid=1001(devuser) gid=1001(devuser) groups=1001(devuser),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023🔲 Reading the chage -l Output
The dates in chage -l are stored in /etc/shadow as numbers of days counted from January 1, 1970. Setting -M 90 -W 14 and -E 2026-12-31 and putting the two outputs side by side showed that 20771 is the Nov 14, 2026 of Last password change and 20818 is the Dec 31, 2026 of Account expires. The 0, 90, and 14 between them are the minimum days, maximum days, and warning days in the bottom three lines of chage -l.
~]# chage -l devuser
Last password change : Nov 14, 2026
Password expires : Feb 12, 2027
Password inactive : never
Account expires : Dec 31, 2026
Minimum number of days between password change : 0
Maximum number of days between password change : 90
Number of days of warning before password expires : 14
~]# grep '^devuser:' /etc/shadow | cut -d: -f1,3-9
devuser:20771:0:90:14::20818:Password expires has no field of its own in /etc/shadow; it was calculated as Feb 12, 2027 by adding the maximum of 90 days to the last change date.
You can type the -M, -E, and -d options yourself in the chage Command Simulator.
Accounts no longer in use are deleted together with their home directory using the userdel command.
5️⃣ Password Validity Period with chage -M, -m, -W
-M is the maximum number of days the password can be used. According to the official manual, once the date obtained by adding these days to the last change date has passed, the account can be used only after the password is changed at login.
chage -M 90 user1-W sets how many days before expiry a warning is shown at login.
chage -W 14 user1-m sets for how many days a password that has just been changed cannot be changed again.
chage -m 1 user1After the three values are set, looking them up shows the Password expires line changed to the last change date plus 90 days.
Last password change : Oct 01, 2026
Password expires : Dec 30, 2026
Password inactive : never
Account expires : never
Minimum number of days between password change : 1
Maximum number of days between password change : 90
Number of days of warning before password expires : 14To turn off the maximum days check, give -1 to -M.
chage -M -1 user1The values a new account gets at first are set in the PASS_ lines of /etc/login.defs. The AlmaLinux 9.8 server and the Debian 12 server both had the same values.
grep ^PASS_ /etc/login.defsPASS_MAX_DAYS 99999
PASS_MIN_DAYS 0
PASS_WARN_AGE 7According to the official manual, these three values apply only when an account is created, and editing the file does not affect existing accounts. Existing accounts are changed one by one with chage.
6️⃣ Account Expiry and Locking with chage -E, -I
-E is the expiry date of the account itself. According to the official manual, after this date the account cannot log in even if the password is valid, and it can be used again only after an administrator changes the expiry date.
chage -E 2026-12-31 user1-I is the number of grace days during which the account can still log in and change the password after the password expires. After that period, the account is locked.
chage -I 7 user1When the two values are set on an account with a maximum of 90 days and then looked up, the Password inactive line shows the password expiry date plus 7 days, and the Account expires line shows the specified account expiry date.
Last password change : Oct 01, 2026
Password expires : Dec 30, 2026
Password inactive : Jan 06, 2027
Account expires : Dec 31, 2026
Minimum number of days between password change : 1
Maximum number of days between password change : 90
Number of days of warning before password expires : 14To remove the account expiry date, give -1 to -E.
chage -E -1 user1Looking it up after removing it shows the Account expires line back at never. The difference is that password expiry blocks only logins with a password, while account expiry blocks the login itself.
7️⃣ Forcing a Password Change at the Next Login with chage -d 0
-d is the option that changes the last password change date. According to the official manual, setting it to 0 forces the password to be changed at the next login.
chage -d 0 user1Looking it up in this state shows the three lines from Last password change to Password inactive changed to [password must be changed].
Last password change : password must be changed
Password expires : password must be changed
Password inactive : password must be changed
Account expires : never
Minimum number of days between password change : 1
Maximum number of days between password change : 90
Number of days of warning before password expires : 14A date can also be written directly.
chage -d 2026-10-29 user1A date set this way is recorded as the day the password was changed, and the password expiry date and the day warnings start are recalculated from that date.
🔢 FAQ & Recommended Content
Creating accounts
useradd Command: Options, -m and -s Usage, and Setting Passwords with passwd
A post on the steps for creating an account with useradd and setting its password with passwd, and on the structure of /etc/skel and /etc/passwd.
sudo privileges
[Linux] How to Grant root Privileges to a Regular User
A post that compares three ways to give a regular user root privileges by editing /etc/sudoers, /etc/passwd, and /etc/group.
ℹ️ Affiliate Disclosure
This site's content contains affiliate links. When a visitor buys a product or service through one of them, the site receives a commission from the seller. The amount the buyer pays(it goes down during event discounts ↓)does not go up. Posted prices, discounts, and stock reflect the time of writing and may differ, so confirm with the seller before buying. Products are chosen and reviewed by our own standards, and commissions do not affect the order or content of reviews.