How to change a Linux password?

How to change a Linux password?

How to change your password in Linux

To change the password for the currently logged in user, you can simply use the passwd command. The process is quick and simple. Here're the step by step instructions:

  1. Open the Terminal window.

  2. Type passwd and tap Enter.

  3. Now you will be prompted to enter your new password and confirm it by retyping it once more.

  4. Please note that your new password will not appear on the Terminal window. This is a security measure that prevents someone from looking over and simply seeing your password. So be extra careful when typing out the password.

  5. Once the change is successful you will see “Password updated successfully” in the terminal windows.

  • Make sure to create a strong password. A strong password should comprise at least 12 characters and include a mix of upper and lower-case letters, numbers, and special characters.

  • Make sure to have a unique password for your Linux device. Reusing passwords for multiple accounts makes it possible for bad actors to hack into an account to have access to others associated with that same user.

  • Use a password generator to create your new password. A password generator is designed to come up with strong, complex, and long passwords on demand.

How to change another user's password in Linux

To change a password for another user in Linux, you need to be logged in as a root user. Here's how you can do it:

  • Open the Terminal window.

  • Type the su - or sudo -i command and tap Enter.

  • Now as a root user, type the passwd command followed by a username for which you wish to prompt a password change: passwd username

  • Now enter the new password for the user and confirm it by retyping to it once more.

  • Tap Enter and you're all done!

How to force password reset in Linux

In some instances you might want to force a password reset procedure for a specific user: either for reusing the password across multiple accounts or because you know that the user's password was exposed in a breach. Whatever the reason might be, you can force a password reset in Linux with the help of a passwd command. Here're step-by-step instructions of how to do it:

  • Open the Terminal window.

  • Type the su - or sudo -i command and tap Enter.

  • Now as a root user, type the passwd command followed by a username for which you wish to prompt a password reset procedure: passwd -e username

  • That's it. The next time the user for whom the reset procedure has been prompted will be asked to reset their password.

Previous post Next post