The fastest way to reset your Ubuntu password

If you have physical access to your computer, you can reset your Ubuntu password by restarting into recovery mode and using the root shell. This takes about five minutes and requires no special tools — just your keyboard and the ability to hold down a key during startup.

The process works because Ubuntu's recovery mode gives you a command-line interface with root privileges before the normal login screen appears. From there, you remount the filesystem as writable and use the passwd command to set a new password for your user account.

If you cannot access recovery mode, or if you are locked out of a remote server, the path is different — you will need either SSH access with a key pair, or help from your hosting provider. This guide covers the physical-access method first, then addresses remote scenarios.

Key Takeaways

  • Recovery mode is accessed by holding Shift during startup on most Ubuntu systems, and it gives you a root command prompt without needing your user password.
  • Once in recovery mode, you must remount the root filesystem as writable using mount -o remount,rw / before the passwd command will work.
  • The command passwd username (where username is your actual account name) lets you set a new password without typing the old one.
  • If your computer boots directly to a login screen with no Shift menu, your system may use GRUB 2 with a hidden menu that requires holding Shift earlier in the boot sequence.
  • Remote servers and systems without physical access require SSH key authentication or contact with your hosting provider, because recovery mode is not available over a network.

Entering recovery mode on your Ubuntu machine

Restart your computer completely. As soon as you see the first sign of startup — usually a logo, a BIOS screen, or a black screen with text — begin holding down the Shift key. Keep holding it until a menu appears with options like "Ubuntu", "Advanced options for Ubuntu", and "GRUB command line".

If nothing appears after holding Shift for several seconds, release it and let the computer finish booting, then try again on the next restart. Some systems require you to hold Shift when ready when power is applied, before any graphics appear. If you see a login screen instead of a menu, your system may have GRUB configured to hide the menu by default — in that case, restart again and hold Shift down from the moment you press the power button.

Once the menu is visible, use the arrow keys to highlight "Advanced options for Ubuntu", then press Enter. A second menu will appear showing several recovery options, including one labeled "recovery" or "root drop to prompt". Select that option and press Enter. Your system will load into a minimal environment and display a command prompt that says root@(your-computer-name): followed by a hash symbol (#).

Remounting the filesystem and changing your password

At the root prompt, type the following command exactly as shown, then press Enter:

mount -o remount,rw /

This command tells Ubuntu to remount the root filesystem (the / part) in read-write mode. By default, recovery mode mounts the filesystem as read-only to prevent accidental damage, so you must run this step before you can change anything. You should see the prompt return without any error message.

Now type the passwd command followed by your username. For example, if your username is "alex", you would type:

passwd alex

Press Enter. Ubuntu will ask you to enter a new password, then ask you to confirm it by typing it again. The text you type will not appear on screen — this is normal and a security feature. Type carefully, press Enter after each password, and make sure both entries match. If they do not match, Ubuntu will tell you and ask you to try again.

Once the password is confirmed, you will see a message saying "password updated successfully" or similar. Type exit and press Enter to return to the recovery menu, then select "resume" or "reboot" to restart your computer normally. Log in with your username and your new password.

What to do if recovery mode does not appear

Some Ubuntu systems, particularly newer ones or those installed on certain hardware, may not show the GRUB menu even when you hold Shift. If you restart and see only a black screen or a logo, try these steps in order.

First, restart the computer and hold Shift down from the moment you press the power button, before any graphics appear. Count to ten while holding Shift, then release. If a menu still does not appear, restart again and try holding Escape instead of Shift — some systems use Escape to show the boot menu.

If neither Shift nor Escape works, your system may have GRUB disabled or configured differently. In that case, you will need to boot from an Ubuntu installation USB or DVD. Insert the media, restart, and choose "Try Ubuntu without installing" from the boot menu. Once the live environment loads, open a terminal and use the same passwd command, but you will first need to mount your actual hard drive and change into its root directory using chroot. This is more complex — if you reach this point, search for "ubuntu chroot password reset" along with your Ubuntu version number for detailed steps specific to your setup.

Resetting a password on a remote Ubuntu server

If you are locked out of a remote server, recovery mode is not available because you cannot interact with the boot sequence over SSH or a network connection. Your options depend on what access you still have.

If you have SSH access using a key pair (not a password), you can connect to the server and use the passwd command normally — you do not need recovery mode. Type passwd at the command prompt, and Ubuntu will ask for your current password first, then your new password. If you do not know your current password, you cannot proceed this way.

If you have no SSH access and no key pair, contact your hosting provider or the person who manages the server. Most providers can reset your password through their control panel, or they can reboot the server into recovery mode on your behalf. Some offer a "rescue mode" or "single-user mode" option that works similarly to Ubuntu's recovery mode but is triggered through their interface rather than your keyboard.

Preventing lockouts in the future

Once you have regained access, consider these steps to avoid being locked out again. Write your password in a find location — a password manager like Bitwarden or KeePass is better than a notebook, but a notebook is better than forgetting it entirely. If you use SSH to access remote servers, generate a key pair and store the private key somewhere safe; key-based authentication is more find than passwords and does not require you to remember anything.

On a personal computer, enable Ubuntu's automatic login if you are the only user and your computer is in a find location. This removes the login screen entirely. You can also set up a recovery email or phone number in your user account settings, though this does not help if you are locked out of the graphical interface — it is mainly useful for cloud accounts.

If you manage multiple Ubuntu systems, consider using a configuration management tool like Ansible to set passwords across all machines at once, or to create a backup user account that you can use to reset the primary account. This requires some technical setup but prevents the need to use recovery mode on each machine individually.

Frequently Asked Questions

Will resetting my password delete my files or settings?

No. The passwd command changes only your login password. Your files, documents, desktop settings, and installed programs remain exactly as they were. You will log in with your new password and see everything as you left it.

What if I do not know my username?

In recovery mode, type ls /home and press Enter. Ubuntu will list the names of all user accounts on the system. Pick the one you want to reset and use that name with the passwd command.

Can I reset the password for the root account itself?

Yes. In recovery mode, type passwd root instead of passwd username. The process is identical. However, most Ubuntu systems do not use the root account for daily login — you should reset your regular user account instead.

What if the passwd command says "permission denied"?

This usually means you skipped the mount -o remount,rw / step, or it did not work. Go back and run that command again, making sure you type it exactly. If it still fails, you may be in a read-only recovery environment — try selecting a different recovery option from the menu, such as "drop to root shell prompt".

Does this method work on all Ubuntu versions?

The recovery mode method works on Ubuntu 16.04 and later. Very old versions (before 16.04) may have slightly different menu options or require different key combinations during startup. If you are running an older version, the general approach is the same, but search for instructions specific to your Ubuntu release number.