TechEarl

Force a Password Change at Next Login on Linux

Expire a password with chage -d 0 or passwd -e so the user must set a new one the next time they log in. The difference from locking, and how to undo it.

Ishan Karunaratne⏱️ 4 min readUpdated
Share thisCopied
Expire a Linux password with chage -d 0 or passwd -e so the user must set a new one at next login, without locking the account.

After you reset someone's password, you do not want them keeping the temporary one you chose. Force them to pick their own at next login by expiring the current password. Two commands do it; both need root:

bash
sudo chage -d 0 deploy        # set last-change date to epoch = already expired
sudo passwd -e deploy          # same effect, shorter to type
Root terminal showing chage -l for a user, then chage -M 90 -W 7 and chage -d 0 to force a password change at next login, with the aging fields updated.
chage -d 0 sets the last-change date to the epoch, so the password counts as expired and must be reset on next login.

What the user sees

On their next login they get You are required to change your password immediately (administrator enforced), then the normal change-password flow. They cannot reach a shell until they set a new password. After that, the account behaves normally.

This is not the same as locking

It is a common mix-up:

GoalCommandEffect
Make them reset the passwordchage -d 0 / passwd -eThey log in once, then must choose a new password. Access continues.
Stop them logging in at allusermod -L + nologin, or chage -E 0Access blocked entirely. See lock and unlock.

Forcing a change is the right move after an admin reset or a suspected weak password. Locking is for revoking access.

Undo it

If you expired the password by mistake, restore a normal last-change date:

bash
sudo chage -d $(date +%Y-%m-%d) deploy     # set last-change to today

Or simply have them complete the change once; after they set a new password the expiry clears on its own.

Caveat: it only forces password logins

Expiring the password forces a reset for password-based logins. A user who logs in by SSH key bypasses the password entirely, so chage -d 0 will not prompt them. If you need to force key users through something, that is an account-expiry or key-rotation task, not a password one.

FAQ

See also

Sources

Authoritative references this article was fact-checked against.

TagsLinuxchagepasswdPasswordSecurity

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

How to Disable Root Login on Linux

Disable direct root login over SSH and on the console, lock the root password, and move everyone to a normal account plus sudo, without locking yourself out.