How to Change User Password in Linux With Examples

In this tutorial, we will focus on how you can change a user’s password in Linux. We will delve deeper and see how to force a user to change their password the next time they try logging in. These commands are standard and will work for any Linux distribution.

Let’s jump right in.

1. Changing your user password

As a regular user in a Linux system, you can only change your password. The root user is the only user that can change the passwords of other users.

The command used for changing users’ password is the passwd command. It is usually followed by the username of the user whose password you want to change i.e.

For example, if you want to change the password of a user jamie, execute

You will be prompted to type your current password and later provide the NEW password and confirm it.

Sample Output


When providing a new password , ensure that you use a STRONG and UNIQUE password. A strong password should have the following.

  1. It should have a combination of Uppercase, Lowercase, Numeric and Special characters
  2. It should have more than 8 Characters
  3. It should not contain your biometric details such as name, date of birth, place of residence to mention a few.

Passwords are stored in an ecrrypted format in the /etc/gshadow file.

2. Changing Linux password for another user

As discussed before, only the root user can change other users’ password. So, you need to log in as the root user to do this.

Once logged in run the command as earlier shown to change a users password

Once again, you will be prompted for the new password and asked to confirm it.

Sample Output


3. Forcing a user to change password at the Next Login

Usually, passwords are not set to expire. But, you can force a user to change their password the next time they log in to the Linux system.

To do this , use the passwd command with --expire option followed by the username of the user:


The next time user logs in with their old password, they will be forced to change the password.

Sample Output


That concludes this tutorial on How to change a user’s password in Linux. Your contribution and feedback are most welcome.

By admin

Leave a Reply