How to Reset a Forgotten Ubuntu Password (Step-by-Step Guide)

How to Reset a Forgotten Ubuntu Password (Step-by-Step Guide)

A forgotten Ubuntu password does not mean a lost computer. Ubuntu has a built-in recovery mode that opens a root shell, and from that shell a single command sets a new password for any user account. The fix takes about ten minutes once the recovery menu is on screen, and it leaves files and settings where they were. This guide covers Ubuntu 24.04 LTS and explains every command before asking the reader to type it.

One warning comes before anything else, because it decides whether the steps below can work at all. If the disk is encrypted and the encryption passphrase is also forgotten, no password reset can open the disk, and the data on it cannot be recovered. That is a different problem from a forgotten login password, covered in its own section below. If the disk is not encrypted, or the encryption passphrase is remembered, carry on: the login password can be reset. This guide does not cover Ubuntu running inside Windows through WSL, where the password reset works differently.

First, work out which situation you are in

There are four ways back into a locked-out Ubuntu system, and the right one depends on what still works. A second administrator account is the fastest route when one exists. Recovery mode is the standard route for a fully locked-out desktop. Editing the GRUB boot entry is the fallback when recovery mode is missing. A live Ubuntu USB is the last resort when the boot menu itself is the problem.

Your situationUse this methodWhat you need
Another administrator account still signs inReset from that accountThe other account password
Locked out, disk not encryptedRecovery modePhysical access
Locked out, disk encrypted, passphrase rememberedRecovery mode, after unlocking the diskThe encryption passphrase
Recovery mode is missing or will not openEdit the GRUB boot entryPhysical access
The GRUB menu will not appear at allLive Ubuntu USBA bootable Ubuntu USB, plus the disk passphrase if encrypted
Disk encrypted and the encryption passphrase is forgottenNo reset method worksA saved recovery key, or a reinstall
Flowchart for choosing how to reset a forgotten Ubuntu password: another admin account, recovery mode, the GRUB edit method, a live USB, or the encrypted disk branch

All four methods need physical access to the computer, because the whole point is to interrupt the boot process before the login screen appears.

Method 1: Reset the password from another administrator account

If a second account on the same computer still signs in and has administrator rights, use it. This is the quickest method by far, it needs no reboot, and it carries the least risk. Skip to recovery mode below if no second administrator account exists.

  1. Sign in with the working administrator account.
  2. Open a terminal with Ctrl, Alt, and T pressed together.
  3. Type the command below, replacing username with the login name of the locked-out account, then press Enter. The sudo part runs it with administrator rights, and passwd is the tool that changes a password.
sudo passwd username
  1. Type the administrator account own password when asked, then press Enter. Nothing shows on screen while typing a password.
  2. Type the new password for the locked-out account, press Enter, then type it again to confirm. The message passwd: password updated successfully confirms the change.
  3. Sign out, then sign in to the locked-out account with the new password.

The new password takes effect straight away, for the login screen and for sudo commands. If the locked-out account was the only administrator, this method cannot help, and recovery mode below is the route instead.

Method 2: Reset the password from recovery mode

Recovery mode is Ubuntu built-in repair environment. It loads a minimal system, skips the normal login screen, and offers a menu that includes a root shell, a command prompt with full administrator rights. From there, the passwd command sets a new password for any account. The steps below are written for Ubuntu 24.04 LTS, and Ubuntu own recovery mode documentation lists the same menu path and remount command.

  1. Restart the computer. At the login screen, use the power menu in the top right corner and choose Restart.
  2. As the computer starts up again, bring up the GRUB boot menu. On a computer that boots the older BIOS way, hold the Shift key. On a computer that boots with UEFI, press the Esc key repeatedly. If the Ubuntu logo appears, the moment has passed, so restart and try again.
  3. When the GRUB menu appears, highlight Advanced options for Ubuntu and press Enter.
  4. Select the entry ending in (recovery mode), usually the second line, which looks like Ubuntu, with Linux 6.8.0-31-generic (recovery mode). The numbers are the kernel version, so pick the newest one listed. Press Enter.
  5. After a few moments a recovery menu appears. Use the arrow keys to highlight root, Drop to root shell prompt, and press Enter. If the screen asks to press Enter for maintenance, press Enter.
  6. The root filesystem is mounted read-only at this point, which means nothing can be changed yet. Run the command below to remount it with write access.
mount -o remount,rw /
  1. If the username is also forgotten, list the home folders to find it. Each folder name is a username.
ls /home
  1. Set the new password with the command below, replacing username with the account login name, then press Enter. Because it runs as root here, passwd does not ask for the old password first.
passwd username
  1. Type the new password when prompted, press Enter, then type it again to confirm. Nothing appears on screen while typing, which is normal for passwords on Linux. The message passwd: password updated successfully confirms the change. If it does not appear, read the troubleshooting section before rebooting.
  2. Restart with the command below, then sign in with the new password.
reboot
Diagram of the recovery mode password reset path: open GRUB, choose Advanced options, then recovery mode, then root shell, then remount and passwd, then reboot

What each command in recovery mode actually does

The mount command changes the root filesystem from read-only to read-write, because a password change writes to the system password file and a read-only filesystem refuses all writes. The ls /home command lists the folders inside home, and since every user account gets a folder named after its username, this reveals the exact login name to type. The passwd username command asks for the new password twice so a typo gets caught, then writes the result to the system password file.

See also  Linux Lite vs Lubuntu: Which Is the Best Lightweight OS for an Old Laptop?

Method 3: Edit the GRUB boot entry when recovery mode is missing

Some systems have no recovery mode entry in the Advanced options menu, and Ubuntu Server and minimal installs often ship without one. The GRUB edit method reaches the same root shell by a different route: it changes the boot instructions for one boot only, telling the kernel to start a shell instead of the normal system. Nothing is saved, so the next boot runs normally. Ubuntu own lost-password documentation describes the same edit.

  1. Restart the computer and bring up the GRUB menu the same way as for recovery mode: hold Shift on a BIOS system, or press Esc repeatedly on a UEFI system.
  2. Highlight the normal Ubuntu entry, usually the first line, and press e to edit it. The boot instructions for that entry open for editing.
  3. Find the line that starts with linux. It is long and may wrap across the screen, but it is a single line, and it ends with words like quiet splash. Move the cursor to the very end of that line.
  4. Change the word ro on that line to rw, so the root filesystem mounts read-write instead of read-only.
  5. Add init=/bin/bash at the very end of the same line, with a space before it. This tells the kernel to run a bash shell instead of the normal startup system, which drops straight to a root shell with no login prompt.
  6. Press Ctrl and X together, or F10 on some systems, to boot with the edited line. The computer starts up and stops at a root shell prompt, a plain text line ending in a hash sign.
  7. Run the remount command as a safety step, then set the new password exactly as in recovery mode.
mount -o remount,rw /
passwd username
  1. Type the new password twice when prompted, and wait for the message passwd: password updated successfully.
  2. Save any pending writes with the sync command, then force a restart. A plain reboot will not work here, because the normal startup system never started. The reboot -f command forces an immediate restart instead.
sync
reboot -f

When the computer restarts, sign in with the new password. Pressing Esc discards the edit and returns to the menu without changing anything, so a wrong keypress can be undone. The edit never touches any file on disk, which is why this method is safe to retry.

See also  The 6 Best Linux Desktop Environments in 2026 (A Guided Tour)

Method 4: Reset the password from a live Ubuntu USB

When the GRUB menu will not appear at all, or when both methods above fail, a live Ubuntu USB is the remaining route. The USB boots a complete Ubuntu system that runs from the stick, and from there the installed system can be opened and its password changed. It needs a second computer to create the USB, so treat it as the fallback rather than the first try.

  1. Create a bootable Ubuntu USB if one is not already available. The guide to creating a bootable Ubuntu USB on Windows covers the download, the checksum check, and writing the image.
  2. Plug the USB into the locked-out computer, start it, open the boot menu, usually with F12, F10, or Esc, then choose the USB stick. Select Try Ubuntu rather than Install Ubuntu when the menu appears.
  3. Once the live desktop loads, open a terminal with Ctrl, Alt, and T.
  4. List the disks to find the Ubuntu root partition. The lsblk command shows every disk and partition with its size and filesystem type, and the root partition is usually the largest Linux partition.
lsblk -f
  1. Mount the root partition under mnt, replacing sdXY with the partition found above, for example sda2 or nvme0n1p2. If the disk is encrypted, unlock it first with the encryption passphrase, because a locked encrypted partition cannot be mounted.
sudo mount /dev/sdXY /mnt
  1. Connect the live system folders into the mounted system, then switch into it with chroot, which makes the mounted system the new root, so later commands run inside the installed Ubuntu rather than the live USB system.
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo chroot /mnt
  1. Set the new password with the same passwd command used in the other methods, replacing username with the account login name. If the username is unknown, ls /home inside the chroot lists it.
passwd username
  1. Type exit to leave the chroot, unmount everything, and restart. Remove the USB stick when the computer restarts, then sign in with the new password.
exit
sudo umount /mnt/sys /mnt/proc /mnt/dev /mnt
sudo reboot

The live USB method changes only the password. It does not reinstall anything and does not touch personal files. The one risk is mounting the wrong partition, which is why the lsblk step matters.

If the disk is encrypted and the encryption passphrase is forgotten

Ubuntu full-disk encryption, called LUKS, scrambles everything on the disk until the right passphrase is entered. The login password and the encryption passphrase are two separate secrets: the login password guards the user account, and the encryption passphrase guards the disk itself, asked before the login screen ever appears. Resetting the login password only changes the account, so it cannot open an encrypted disk whose passphrase is lost.

Diagram of the encrypted disk branch: passphrase remembered means unlock then reset the login password; passphrase forgotten means check for a recovery key, or the data cannot be recovered

Work through these checks in order. First, decide which secret is actually lost. If the computer asks for a passphrase on a black screen before Ubuntu starts, that is the encryption passphrase. If it reaches the login screen and rejects the password there, that is the login password, and the methods above apply. Second, try every plausible variant of the lost passphrase, including a different keyboard layout, because the wrong layout produces different characters. Third, look for a saved recovery key or a second passphrase. If either exists, use it to unlock the disk, then reset the login password with the methods above.

If none of those exist, the data cannot be recovered. LUKS encryption is designed so that no password reset, live USB, or recovery tool can open the disk without the passphrase, the same property that protects the data when a laptop is stolen. The only path forward is a fresh install, which erases the disk, covered in the guide to installing Ubuntu 24.04 LTS step by step.

See also  The 7 Best Linux Distros for Raspberry Pi in 2026 (Matched to Your Pi)

After the reset: the keyring prompt and a quick sudo test

Signing in with the new password is usually the end of the story, but one after-effect is common: a popup after login asking to unlock the Login keyring. Ubuntu stores saved Wi-Fi passwords and app passwords in a keyring with its own password, which normally matches the login password. A password changed from recovery mode bypasses the normal change process, so the keyring keeps the old login password. If the old password is remembered, type it once to unlock the keyring, then open Passwords and Keys, right-click Login, choose Change Password, and set the keyring password to the new login password. If the old password is also forgotten, the only fix is to delete the Login keyring, which loses the passwords stored inside it.

The second check is sudo. Open a terminal and run sudo -v, then type the new password when asked. A silent return with no error means sudo accepts the new password. If sudo reports that the account is not in the sudoers file, the account was never an administrator, and only an administrator account can fix that. Also confirm the new password works after a full restart.

When it does not work: the errors people actually hit

Most failures in this process come from three causes: the GRUB menu never appearing, the filesystem still being read-only, or the new password being typed differently at the login screen.

What happensWhat it meansFix
The GRUB menu never appearsThe key was pressed too late, or fast boot skipped the windowRestart and hold Shift or press Esc earlier, and try turning off fast boot
Authentication token manipulation errorThe filesystem is still read-only, so the password file cannot be writtenRun mount -o remount,rw / again, then retry passwd
Give root password for maintenanceThe root account has its own password setUse the GRUB edit method instead, which needs no root password
New password rejected at the login screenA typing difference between the shell and the login screenCheck Caps Lock and the keyboard layout, then reset again with a simple password
passwd reports the user does not existThe username was typed wrongRun ls /home and copy the folder name exactly
reboot does nothing in the GRUB edit shellSystemd never started, so nothing handles the rebootRun sync, then reboot -f to force an immediate restart

The GRUB timing problem is the most common reason people conclude the method does not work. On UEFI systems with fast boot enabled, the window to press Esc can be under a second. Restarting from the login screen rather than from a full shutdown sometimes leaves the GRUB menu visible on the next boot. In a virtual machine, click into its window first.

Once you are back in: stop this happening again

Three habits make a repeat lockout unlikely. First, store the new password in a password manager. Second, create a second administrator account, even if it is rarely used, because Method 1 turns a lockout into a two-minute fix. Third, if the disk is encrypted, store the encryption passphrase separately from the login password, because a forgotten encryption passphrase has no reset path at all.

A forgotten Ubuntu password is a ten-minute problem on an unencrypted disk: open the GRUB menu, pick recovery mode, remount the filesystem with write access, and set a new password with passwd. The encrypted-disk check comes first, because it is the one case where the reset cannot help. Keep the new password somewhere safe, and the next lockout will be a minor interruption.

Lokesh Sharma
Scroll to Top