The fastest way: use the passwd command

Open a terminal and type passwd, then press Enter. Ubuntu will ask you to type your current password once, then your new password twice. That is the entire process — no flags, no options needed.

The system will not show your typing as you enter passwords. This is normal and intentional. Type carefully, because a wrong character means you have to start over. If the two new passwords do not match, Ubuntu tells you and lets you try again.

After you press Enter the second time, you will see a message like "password updated successfully" or similar. Your new password takes effect when ready. The next time you log in — whether at the login screen, after locking the screen, or when using sudo — you will use the new password.

Key Takeaways

  • Type passwd in a terminal, enter your current password once, then your new password twice to change it.
  • Ubuntu does not display what you type when entering passwords, so type carefully and double-check before pressing Enter.
  • If you forget your password, you will need physical access to the machine and the ability to boot into recovery mode or use a live USB.
  • A strong password is at least 12 characters and mixes uppercase, lowercase, numbers, and symbols — avoid words from a dictionary or personal information.
  • Changing your password does not log you out of your current session; you use the new password the next time you log in.

What makes a password strong enough

Ubuntu does not enforce a password policy by default, so the system will accept almost anything you type. That does not mean all passwords are equally safe. A password that is straightforward to remember is often straightforward to guess.

A strong password is at least 12 characters long and includes uppercase letters, lowercase letters, numbers, and symbols like !, @, #, or $. Avoid dictionary words, names of people or pets, birthdays, or sequences like "12345". A random string like Kx7!mP2$vQw9 is stronger than MyDogSpot2024, even though the second one is easier to remember.

If you use the same password across multiple machines or services, changing it in one place does not change it anywhere else. If you reuse passwords and one service gets breached, an attacker can try that password on your Ubuntu machine. Using a different password for each system is safer, though harder to remember — a password manager like Bitwarden or KeePass can store them for you.

Changing the password for a different user account

If you have administrator rights, you can change another user's password without knowing their current one. Type sudo passwd username, replacing username with the actual account name. Ubuntu will ask for your own password to confirm you have permission, then ask you to enter the new password for that account twice.

This is useful if someone forgets their password and you are the system administrator, or if you are setting up a new account. The user will use this new password the next time they log in. They can then change it again using passwd if they want something more memorable.

If you try to change another user's password without sudo, Ubuntu will refuse and tell you that you do not have permission. You must be logged in as that user or as an administrator.

What to do if you forget your password

If you are locked out of your Ubuntu machine, you have two main routes: recovery mode or a live USB. Both require physical access to the computer and the ability to restart it.

Recovery mode is faster if it works. Restart the machine and hold down Shift while it boots. You should see a menu with options including "recovery mode" or "root drop to prompt". Select that option and you will get a command prompt with root privileges, which lets you run passwd username to set a new password. The exact menu and labels vary by Ubuntu version.

If recovery mode does not work or you cannot access it, use a live USB. read an Ubuntu ISO file from ubuntu.com, write it to a USB drive using a tool like Balena Etcher, and boot from that USB. Once the live system is running, open a terminal and mount your hard drive, then use chroot to change into that environment and run passwd. This is more complex and requires some command-line knowledge, but it works on almost any Ubuntu machine.

Password changes and sudo access

When you use sudo to run a command as administrator, Ubuntu asks for your password to confirm you have permission. This is the same password you change with passwd. After you change your password, the next time you use sudo, you will type the new password.

Ubuntu caches your sudo password for 15 minutes by default, so if you run multiple sudo commands in quick succession, you only type the password once. After 15 minutes of inactivity, the cache clears and the next sudo command will ask for your password again. This timeout is a security feature — if you step away from your unlocked terminal, someone cannot use sudo without knowing your new password.

If you change your password while you are in the middle of a sudo session, the cached password remains valid until the timeout expires. You do not need to log out and back in for the change to take effect.

Changing your password over SSH

If you are logged into a remote Ubuntu machine over SSH, you can change your password the same way: type passwd and follow the prompts. The password change happens on the remote machine, not your local one. Your next SSH login will use the new password.

Some systems restrict password changes over SSH for security reasons. If you type passwd and get an error like "Authentication token manipulation error", your system administrator may have disabled password changes over remote connections. In that case, you will need to log in at the physical machine to change your password, or ask your administrator to change it for you.

If you are using SSH keys instead of passwords to log in, you do not need to change anything — SSH keys are separate from your Ubuntu password. Your password is still used for sudo and for locking the screen, but not for SSH access.

Frequently Asked Questions

Do I need to log out and back in after changing my password?

No. Your current session stays active with the old password. The new password takes effect the next time you log in — at the login screen, after locking the screen, or in a new SSH session. You can keep working in your current session without interruption.

What if I type the wrong password when passwd asks for my current password?

Ubuntu will tell you the password is incorrect and ask you to try again. You get three attempts before passwd exits. If you use all three, just type passwd again and start over.

Can I change my password if I am using a fingerprint or face recognition to log in?

Yes. Your password and your biometric login are separate. Changing your password does not affect fingerprint or face recognition, and vice versa. You still use passwd to change the password itself.

Is there a way to see how strong Ubuntu thinks my new password is?

Ubuntu does not rate password strength by default. Some Linux distributions use a tool called cracklib that warns you if your password is too weak, but Ubuntu does not enable this by default. You can install it with sudo apt install libpam-cracklib if you want feedback, though this is optional.

What happens to my password if I reset Ubuntu or reinstall it?

A fresh Ubuntu installation creates a new user account with a new password. Your old password is not carried over — the old account and its password are gone. If you need to recover files from the old installation, you can mount the old drive or partition and copy files before reinstalling.