Linux Commands

How do I reset a Password in Linux

Linux allows users to change their passwords whenever they log in. Linux offers the “passwd” utility to change an existing or a new user account password. Any information that is related to the encrypted user’s password or the password-related details is stored in the “/etc/shadow” file of the Linux system. If you are a normal user, then you can only change the password for your account. But if you are a root user or user with sudo access, you can also change the other users’ password.

Whenever you change the password, make sure that you use a strong and unique password that meets the standard criteria for a Linux password. Having a strong password is a smart move to protect your account from potential thefts and unauthorized access. A strong password should be 16 characters long, containing one uppercase letter, one lowercase letter, one number, and one special character. It is a good habit to update your password frequently to save it from hackers and other unwanted access.

Changing the User Password

To change the password of your user account, run the “passwd” command without any additional argument, as shown below.


After running the above command, the user is prompted to provide the current password to change the password. If the entered password is correct, enter the new password and confirm it by entering again. You can see that the passwords are not shown on the screen. You will be required to enter the new password whenever you log in again.

Changing the Password for Another User

If you want to change the password for another user, use the root user or the user with sudo access. Here in the later examples, we consider that you are using the user with the sudo access.

If you wish to change the password for another user, you will have to use the “passwd’ command along with the desired username for which you are looking to change the password. Here, we are using the user “dum” to change the password.

sudo passwd dum

After running this command, you will be asked to enter the new password and then confirm it. You will get the output as below without displaying your password on the screen.

Enter new UNIX password:
Retype new UNIX password:

Once the process is complete, you will get the below output for the successful password change for that user.

passwd: password updated successfully

Forcefully Changing the User’s Password at the Next Login

By default, the password for any user will not expire. You need to explicitly mention the time and date when the password will be valid for the user. If you want the user to change their password forcefully whenever they log in next time, you can use the “passwd” command along with the “expire” option, as shown below.

sudo passwd --expire dum

It will immediately expire the password of the user “dum”.

So whenever the user logs in with the below command next time, he will get the below message.

ssh dum@

After the user sets the new password for its account, the connection will get closed immediately.


Linux is considered the safest OS and provides a safe working environment by setting a password for their accounts. If you are a normal person, then you can only set the password for your working account. For changing the password for another user on the Linux system, you need to have the root privileges or sudo access to do that. Setting and changing passwords for various users will be done by the Linux administrators, managing the accounts for users.

We hope now you understand the role of the “passwd” command and how to successfully change the password for your and other users’ accounts.

About the author

Simran Kaur

Simran works as a technical writer. The graduate in MS Computer Science from the well known CS hub, aka Silicon Valley, is also an editor of the website. She enjoys writing about any tech topic, including programming, algorithms, cloud, data science, and AI. Travelling, sketching, and gardening are the hobbies that interest her.