How to Change User Password in Linux

Filed Under: UNIX/Linux

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.

# passwd your_username

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

# passwd jamie

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

Sample Output

changing password for a Linux user

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

# passwd username

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

Sample Output

Change User's Password In Linux By Root

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:

$ passwd --expire jamie 

Passwd Expire

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

Sample Output

Log In After Expiry Of Password

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

Leave a Reply

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

close
Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages