How to Change a Password in Linux

Because Linux is inherently a multi-user operating system designed for enterprise networking, password security is taken extremely seriously. If you suspect your password has been compromised in a data breach, or if you simply need to reset the password for a junior developer who forgot theirs over the weekend, you must know how to use the terminal’s built-in cryptographic tools.

You do not need to download third-party software or navigate complex GUI menus. Password management is handled entirely by a single, powerful command: passwd.

How to Change Your Own Password

If you are logged into your own user account and simply want to update your security credentials, the process takes about five seconds.

  1. Open your terminal (or connect to your remote server via SSH).
  2. Type the following command and press Enter:

passwd

The system will immediately prompt you with a three-step security challenge:

  1. Current password: You must first prove you are actually sitting at the keyboard by typing your old password.
  2. New password: Type your desired new password.
  3. Retype new password: Type it exactly the same way to ensure you didn’t make a typo.

Crucial Note: When you type a password in a Linux terminal, the cursor will not move, and absolutely no asterisks (****) will appear on the screen. This is a deliberate security feature designed to prevent people standing behind you from guessing the length of your password. Just keep typing blindly and press Enter when finished.

How to Change Someone Else’s Password

If you are the systems administrator (root), you have the absolute authority to forcefully overwrite the password of any other user on the machine without knowing their original password. This is how you rescue users who have locked themselves out.

  1. You must elevate your privileges using sudo, followed by the passwd command, followed by the specific username. For example, to reset the password for a user named “johndoe”, type:

sudo passwd johndoe

Because you are the administrator, the system skips the “Current password” check entirely. It immediately asks you to type a “New password” and confirm it. The moment you press Enter, John’s old password is cryptographically destroyed and replaced with the new one.

How to Force a User to Change Their Password

If you reset John’s password to a temporary password (like “Welcome123”), it is a massive security risk to let him keep using it. You want him to create his own private password the exact second he logs in.

You can force a mandatory password expiration by using the --expire (or -e) flag.

sudo passwd -e johndoe

This command instantly invalidates the current password. The next time John tries to log in via SSH using “Welcome123”, the server will accept the login, but it will immediately trap him in a mandatory password change sequence. He will not be allowed to access the command prompt until he types a brand new password.

Get the best tech tips delivered straight to your inbox.

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