Skip to content

How to Force User to Change Password at Next Login in Linux

Category
Security

All the Linux systems keeps the users information in /etc/passwd and /etc/shadow files. User password and account aging details are stored in the shadow file. The aging information contains the details of the password change and account status.

In this tutorial, you will learn about forcing a user to change their password in Linux. Also will discuss the content stored in the shadow file.

Force User to Change Password

We use passwd command to create or change user passwords in Linux systems. It also allows us to expire any user’s password. Once the password is expired, the system will allow users to log in but force them to change their password before getting the shell access.

You can view user account and password details run below command as sudo privileges account:

sudo change -l username 

To expire users password, type:

sudo passwd --expire username 

Replace “username” with the actual user name of your system.

Force  user to change password in linux

These commands updates the entries in /etc/shadow file.

Hopefully, this FAQ is helpful for you.

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top