How to Change a User Password on Ubuntu

Whether you suspect your server has been compromised, or you simply forgot your login credentials, knowing how to manage user passwords via the command line is an essential Linux skill.

In Ubuntu, the entire password management system revolves around a single, powerful command: passwd. Here is how to change a user password on Ubuntu, whether you are changing your own password or resetting a forgotten password for someone else.

Method 1: Change Your Own Password

If you are already logged into the server and simply want to update your own password for security reasons, you do not need administrator (sudo) privileges.

  1. Open your terminal or connect to your server via SSH.
  2. Type the following command:
    passwd
  3. Press Enter.

The system will prompt you for your Current password. This proves you are actually the person sitting at the keyboard. As you type, no characters or asterisks will appear on the screen—this is a normal Linux security feature. Press Enter.

Next, it will ask for your New password. Type it, press Enter, and then type it a second time to confirm. Once confirmed, you will see a “password updated successfully” message.

Method 2: Change Another User’s Password

If you are the server administrator and a colleague (let’s say their username is john) has forgotten their password, you can force a reset. Because you are modifying another user’s account, you must use sudo to execute the command with root privileges.

  1. Open your terminal.
  2. Type the passwd command followed by the username of the account you want to change:
    sudo passwd john
  3. Press Enter.

Because you used sudo, the system will first ask for your password to verify you are an administrator. Once verified, it will immediately ask you to type the New password for the user “john.” Notice that it does not ask for John’s old password; as an administrator, you have the power to overwrite it entirely.

Type the new password twice to confirm. The password is now changed, and John can log in immediately using the new credentials.

Method 3: Force a User to Change Their Password on Next Login

If you just reset a password for a colleague using Method 2, it is a terrible security practice for you to know their password. You should force them to choose a new, private password the very next time they log in.

You can do this by “expiring” the password you just created.

  1. Type the following command (replacing john with the correct username):
    sudo passwd -e john
  2. Press Enter.

The -e flag stands for “expire.” The next time John connects to the server via SSH and enters the temporary password you gave him, Ubuntu will immediately halt the login process. It will force him to type the temporary password one more time, and then mandate that he types a brand-new, secure password before it grants him access to the command line.

Leave a Reply

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

Get the best tech tips delivered straight to your inbox.

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

Receive our best articles and tips delivered straight to your inbox.