How to Change a User Password in Linux Using the passwd Command

Security is a fundamental aspect of Linux administration. Whether you need to update your own password for security compliance, or you are a system administrator who needs to reset a forgotten password for another user, the tool for the job is the passwd command.

The passwd utility allows you to securely change user passwords directly from the terminal line without needing a graphical interface.

How to Change Your Own Password

If you are logged into your Linux account and simply want to change your own password, you do not need special root privileges.

  1. Open your terminal.
  2. Type the following command and press Enter:
    passwd
  3. The system will first prompt you to enter your current password. (Note: For security reasons, Linux does not display asterisks or dots when you type passwords. Just type it blindly and press Enter.)
  4. Next, it will prompt you for your New password.
  5. Finally, it will ask you to Retype new password to confirm you didn’t make a typo.

If everything matches, the terminal will display a success message (usually “passwd: password updated successfully”). Your new password takes effect immediately.

How to Change Another User’s Password

If you are a system administrator and a user (let’s say a user named “sarah”) has forgotten their password, you can force a password reset for them.

Because you are modifying another user’s account, you must have root privileges (via sudo).

  1. Open your terminal.
  2. Type sudo passwd followed by the exact username of the account you want to change. For example:
    sudo passwd sarah
  3. Press Enter. You will likely be prompted for your sudo password first to verify your administrative rights.
  4. Because you are acting as root, the system will not ask for Sarah’s current password. It will immediately prompt you for the New password for her account.
  5. Retype the new password to confirm.

How to Force a User to Change Their Password on Next Login

If you are an administrator resetting a password for someone else, it is bad practice for you to know their permanent password. Instead, you should assign them a temporary password and force them to change it immediately upon their next login.

You can do this by “expiring” their current password.

  1. First, reset their password to something temporary (like “Welcome123”) using the sudo passwd username command described above.
  2. Next, run the following command to immediately expire that temporary password (replace “username” with the actual user):
    sudo passwd -e username

The next time that user logs into the Linux system via the terminal or SSH, the system will accept the temporary password but will immediately halt the login process and force them to choose a new, permanent password before granting them access.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.