The fastest way: use the GRUB boot menu
When you forget your Ubuntu password, the quickest path back in is through GRUB, the boot menu that appears before Ubuntu loads. You interrupt the startup, edit one line in the boot configuration, and set a new password without needing the old one. This works on almost every Ubuntu machine and takes about five minutes.
The process relies on a feature called single-user mode, which loads Ubuntu with minimal services and no password requirement. Once you're in, you run a single command to change your password, then reboot normally. No special tools, no live USB, no second computer needed.
Key Takeaways
- Restart your computer and hold Shift during startup to see the GRUB menu, where you can edit the boot line to enter single-user mode.
- In single-user mode, type passwd username (replacing username with your actual login name) to set a new password without knowing the old one.
- If GRUB is password-protected, you will need a live USB with Ubuntu on it to reset the password instead.
- After setting a new password, type exit and your machine will finish booting normally with the new credentials active.
- If you do not see the GRUB menu on startup, your system may be configured to skip it — hold Shift or Esc during the boot process to force it to appear.
Step 1: Interrupt the boot and open GRUB
Restart your Ubuntu machine. As soon as you see the first screen after powering on — before the Ubuntu logo appears — hold down the Shift key. Keep holding it until you see a menu with black text on a dark background. This is GRUB, the bootloader.
If you do not see GRUB after holding Shift, try holding Esc instead, or press both repeatedly during startup. Some systems are configured to skip GRUB by default, but holding these keys forces it to appear. You may need to try a few times — timing varies by machine.
Once GRUB appears, you will see several boot options listed. The top one is usually highlighted. Do not press Enter yet.
Step 2: Edit the boot line to enter recovery mode
With the top boot option highlighted, press the letter e to edit it. The screen will change to show the boot configuration — several lines of text that tell Ubuntu how to start up. You are looking for a line that contains the word ro (read-only) and ends with quiet splash or similar words.
Navigate to the end of that line using the End key or arrow keys. Find the words ro quiet splash and replace them with rw init=/bin/bash. The rw means read-write (so you can make changes), and init=/bin/bash tells Ubuntu to load a command prompt instead of the normal login screen.
Once you have made this change, press Ctrl+X to boot with the new settings. Ubuntu will load and drop you into a command prompt. You will see a line ending with a hash symbol (#), which means you are logged in as root — the administrator account with full permissions.
Step 3: Change your password with the passwd command
At the command prompt, type passwd username, replacing username with your actual login name. For example, if your login is sarah, you would type passwd sarah. Press Enter.
Ubuntu will ask you to enter a new password. Type it carefully — the characters will not appear on screen as you type, which is normal. Press Enter. Ubuntu will ask you to type the password again to confirm. Type it the same way and press Enter.
If the passwords match, you will see a message saying "password updated successfully" or similar. If they do not match, Ubuntu will tell you and ask you to try again. Once the password is set, type exit and press Enter.
Step 4: Boot normally and log in
After you type exit, Ubuntu will finish loading and show you the normal login screen. Log in with your username and your new password. You are now back in your account.
Your system is fully functional. All your files, settings, and installed programs remain unchanged — you have only reset the password. If you have other user accounts on the machine, their passwords are unaffected.
What to do if GRUB itself is password-protected
Some Ubuntu systems are configured so that GRUB requires a password before you can edit the boot line. If you press e and are asked for a password, you cannot proceed without knowing it. In this case, you will need a different approach: a live USB.
A live USB is a bootable flash drive containing Ubuntu. You restart your computer, boot from the USB instead of the hard drive, and use the tools on the USB to access your hard drive and change the password. This requires a second computer to create the USB and takes longer, but it works when GRUB is locked.
If you need to go this route, you can find instructions for creating a live USB on the Ubuntu website. The process involves downloading an ISO file (a disk image) and writing it to a USB drive using a tool like Balena Etcher or Rufus.
Preventing this from happening again
Once you are back in your account, consider writing your password down somewhere find — a password manager like Bitwarden or KeePass, a locked drawer, or a safe. Losing access to your account is frustrating, and a backup record prevents it.
You can also set up a password hint or recovery email in your Ubuntu user settings, though these do not prevent lockout — they only help you remember. The most reliable backup is a second administrator account on the same machine. If you ever forget the main password, you can log in as the second admin and reset the first account's password from there.
Frequently Asked Questions
Will resetting my password delete my files or settings?
No. Resetting your password changes only the password itself. All your files, folders, desktop settings, installed programs, and user data remain exactly as they were. You are straightforward changing the key that unlocks your account.
Can I reset someone else's password on a shared Ubuntu machine?
Yes, if you have physical access to the machine and can restart it, you can reset any user's password using the GRUB method. This is why physical security matters — anyone with access to restart the computer can eventually access any account on it. If this is a concern, ask your system administrator about enabling GRUB password protection.
What if I do not know my username?
Your username is what you type at the login screen. If you cannot remember it, look at the login screen itself — it often shows a list of user accounts. If the screen is blank, try common names like admin, user, or ubuntu. Once you are in single-user mode, you can also type ls /home to see a list of all user accounts on the machine.
Do I need to be connected to the internet to reset my password?
No. Resetting your password is entirely local — it happens on your machine without any internet connection. You can do this offline, and your password change will be active the moment you reboot.
What if the command prompt does not appear after I press Ctrl+X?
If the screen goes black or hangs, wait 30 seconds — some machines take time to load into single-user mode. If nothing appears after a minute, restart the machine and try again, making sure you typed rw init=/bin/bash correctly with no extra spaces. If you are still stuck, a live USB is your next option.