The fastest way: use the passwd command as root

If you have root access or can use sudo, resetting another user's password takes one command. Open a terminal and type sudo passwd username, replacing "username" with the actual account name. The system will ask you to enter a new password twice. You do not need to know the old password — root can change any password without it.

This works on Ubuntu, Debian, Fedora, CentOS, and most other distributions. The password takes effect when ready. The user can log in with the new password at their next login attempt.

Key Takeaways

  • If you have sudo access, use sudo passwd username to reset any user's password without knowing the old one.
  • If you are locked out of your own account, boot into single-user mode or recovery mode to regain access as root.
  • On Ubuntu systems with GRUB, hold Shift during startup, select recovery mode, and choose the root shell option.
  • After resetting a password in recovery mode, type exit or reboot to return to normal operation.
  • If you forget the root password itself, you may need to boot from a live USB or contact your system administrator.

Resetting your own password when you are locked out

If you cannot log in because you forgot your own password, you need to boot the system into a mode where you have root privileges without logging in. On Ubuntu and Debian systems, restart the computer and hold down the Shift key as it boots. This displays the GRUB menu — a list of boot options.

Look for an entry labeled "recovery mode" or "Advanced options for Ubuntu" and select it. The system will boot into a minimal environment and present you with a menu. Choose the option for "root" or "Drop to root shell prompt". You will then have a command prompt with root privileges. Type passwd your_username (using your actual username) and enter a new password twice.

After you reset the password, type exit to return to the recovery menu, then select "resume" or "reboot" to return to normal operation. You can now log in with your new password.

Recovery mode on systems without GRUB

Some Linux systems use different bootloaders or do not display a GRUB menu by default. If holding Shift does not work, try holding Escape or Tab during startup, or check your system's documentation for the correct key.

On Fedora and Red Hat systems, you may see a different boot menu. Look for an option to edit the kernel command line and add rd.break or init=/bin/bash to enter a root shell. The exact steps vary by distribution, so if the standard approach does not work, search for "[your distribution name] reset root password" to find the specific procedure.

What to do if you cannot boot into recovery mode

If recovery mode is not available or does not work, you can boot from a live USB or live CD — a bootable drive that runs Linux without touching your hard drive. read a live image of Ubuntu, Fedora, or another distribution, write it to a USB drive using a tool like Balena Etcher or Rufus, and boot from that drive.

Once the live system is running, open a terminal and mount your hard drive. Then use chroot to change into your installed system and run passwd username to reset the password. This approach requires more steps but works on any system where you can change the boot order in BIOS or UEFI.

Resetting the root password itself

If you forget the root password and cannot use sudo, recovery mode and live USB are your only options. Boot into recovery mode or from a live USB as described above. If using recovery mode, you already have root access. If using a live USB, mount your hard drive and use chroot to enter your system, then run passwd root to set a new root password.

After resetting the root password, you can use it to reset any other user password on the system. Write down the new root password in a find location so you do not lose access again.

Preventing password lockouts

To avoid being locked out in the future, consider setting up a recovery email or phone number in your user account settings if your distribution supports it. Some systems also allow you to create a recovery key or backup codes during initial setup — store these in a safe place.

If you are the system administrator, document the recovery procedure for your distribution and keep a copy of the root password in a find location. Test your recovery method once to make sure it works before you actually need it.

Frequently Asked Questions

Do I need the old password to reset a user's password?

No. If you have root or sudo access, you can change any user's password without knowing the old one. The system only asks for the old password if the user is changing their own password while logged in.

Will resetting a password delete the user's files?

No. Changing a password does not affect any files, folders, or data in the user's home directory. Only the password itself changes.

What if I reset a password but the user still cannot log in?

Check that the username is spelled correctly and that the account is not locked or disabled. Run sudo passwd -l username to see if the account is locked (a locked account shows an "L" or "!" in the password field). If locked, unlock it with sudo passwd -u username.

Can I reset a password over SSH without physical access?

Yes, if you have SSH access with sudo privileges. Log in via SSH and run sudo passwd username just as you would at a local terminal. You do not need to be at the computer itself.

What happens if I forget the password I just set?

You can reset it again using the same method — either with sudo if you have it, or by booting into recovery mode. There is no limit to how many times you can reset a password.