Force user to change password at login

Jonas Björk
The Fedora Idea
Published in
Nov 22, 2023
Photo by rc.xyz NFT gallery on Unsplash

When we create a new user account in Fedora Linux, say user account douglas, we often set a random password for the account. If we want to force the user to change that password at first login we can use --expire with the passwd command.

$ sudo passwd --expire douglas

When douglas logs in, he will receive this message:

WARNING: Your password has expired.
You must change your password now and login again!
Changing password for douglas.
Current password:

Now douglas can choose his own password, unknown for us.

--

--

Jonas Björk
The Fedora Idea

Linux user since 1994. Working professionally with Linux and Open Source since 2000. Fedora on desktop and RHEL/Rocky/CentOS everywhere else.