How to Reset a Forgotten Password on Linux

If you forgot a Linux login password, you can usually set a new one without reinstalling the operating system. The simplest option is to sign in with a second administrator account and run sudo passwd username. If no administrator account is available, Ubuntu users can reset a local password from the GRUB recovery menu. The recovery steps below are Ubuntu-specific; other distributions may use different menu labels and procedures.

Use these steps only on a system you own or administer. Resetting a local password does not unlock encrypted storage or change a centrally managed account.

Option 1: Use another administrator account

  1. Sign in to a different local administrator account and open Terminal. Run sudo passwd alex, replacing alex with the target account’s login name.

If sudo asks for a password, enter the password of the administrator account you are using. Then type the new password for the locked account twice. The terminal does not echo the characters. A successful reset means the account can use the new password at the next sign-in.

An administrator terminal runs sudo passwd alex and displays a new password prompt.
Example: an administrator can use sudo passwd alex to set another local account’s password.

The superuser can change another local account’s password without its old one, but the account you use must already have sudo rights.

Option 2: Reset a local Ubuntu password in Recovery Mode

If no other administrator account is available, Ubuntu’s GRUB recovery menu provides a root shell for resetting a local password. Commands there can change system files, so follow the steps carefully.

  1. Open GRUB. Restart and hold the right Shift key during Ubuntu startup, as Canonical documents. Highlight Advanced options for Ubuntu and press Enter. If GRUB stays hidden, check the computer maker’s boot instructions; firmware settings vary.
The GRUB menu highlights Advanced options for Ubuntu.
In Ubuntu’s GRUB menu, choose Advanced options for Ubuntu. Menu wording can differ by release.
  1. Choose recovery mode. Select the recovery-mode entry for the kernel you normally boot and press Enter. If unsure, choose the newest installed kernel.
The GRUB submenu highlights an Ubuntu kernel entry marked recovery mode.
Choose a recovery-mode entry for an installed kernel; the version labels depend on the system.
  1. Open the root shell. In the Recovery Menu, choose root — Drop to root shell prompt. This gives administrator access from the local console without requiring the forgotten account password. If the disk is encrypted, you still need its unlock passphrase or recovery key before Ubuntu can access the installation.
Ubuntu Recovery Menu highlights root, Drop to root shell prompt.
Choose root — Drop to root shell prompt to open the recovery shell.
  1. Make the root filesystem writable. If it is read-only, run mount -o remount,rw /. The remount option changes an existing mount; no output can be normal.
A root recovery shell shows the mount -o remount,rw / command.
If the installed root filesystem is read-only, remount it read-write before changing the password.
  1. Confirm the login name. Run ls /home. On most desktop installs, the home-directory name matches the login name, while the display name may differ. If the home path or account is unclear, check the account records instead of guessing.
A root shell shows ls /home and the example home directory alex.
On a typical desktop installation, the name under /home is also the login name.
  1. Set the new password. Run passwd alex, replacing alex with the login name. Enter the new password twice; nothing appears as you type. The passwd utility may reject passwords that do not meet system rules.
A root shell shows passwd alex and two password prompts with no typed characters visible.
Enter the new password twice; the terminal does not display the characters as you type.
  1. Restart and sign in. Type reboot. Remove any installation USB, then sign in with the new password and store it securely.
A Linux login screen displays the alex account and a password field.
After rebooting, enter the new account password at the Linux login screen.

What a password reset does not unlock

  • Full-disk encryption: The disk’s passphrase or recovery key protects data before the operating system loads. Resetting the Linux account password does not replace that key.
  • GNOME keyring: Passwords saved in the Login keyring may still be protected by the old login password after an administrator resets the system account. If prompted, the keyring is a separate store; do not delete it if you need its saved credentials. GNOME explains how to update a keyring when you know its current password.
  • Managed or remote accounts: LDAP, Active Directory, SSO, and other centrally managed accounts must be changed through the identity provider or system administrator. A local passwd command may not control them.

If recovery mode is missing or the command fails

Recovery labels vary, and Fedora, openSUSE, Linux Mint, and other distributions may use different procedures. Avoid copying fixed device paths such as /dev/sda1; disks may use encryption, LVM, Btrfs subvolumes, or separate home partitions. Use your distribution’s current recovery guide. If passwd reports an authentication-token error, verify that you are in the installed system’s root shell and that its root filesystem is writable. Stop if you cannot identify the correct account or partition.

Official references

Leave a Comment

How to Record Speaker Output on Linux with Audacity

How to Record Speaker Output on Linux with Audacity

Capture Linux desktop audio in Audacity by routing its recording stream to your output device’s monitor source. Follow PulseAudio and PipeWire steps, export tips, and fixes for silent tracks.

How to Use Dropbox on Linux: Install and Sync Your Files

How to Use Dropbox on Linux: Install and Sync Your Files

Install Dropbox on Linux from the official package, sign in, sync a local folder, manage selective sync, and check status from the command line.

How to Install Inkscape on Linux: Ubuntu, Fedora, Arch, and More

How to Install Inkscape on Linux: Ubuntu, Fedora, Arch, and More

Install Inkscape from your Linux distribution’s repositories, the Ubuntu stable PPA, Snap, or Flathub, with current commands and notes for choosing a package source.

How to Find and Remove Duplicate Files on Linux With FSlint

How to Find and Remove Duplicate Files on Linux With FSlint

Use FSlint to scan selected Linux folders, review duplicate groups, and safely delete redundant files or learn when hard-link merging is appropriate.

How to Install SABnzbd on Linux and Configure It

How to Install SABnzbd on Linux and Configure It

Install SABnzbd on Ubuntu or Debian, or run it in Docker on another Linux host. Then open the web interface and configure your provider and download folders.

How to Install the Paper GTK Theme on Linux

How to Install the Paper GTK Theme on Linux

Install the Paper GTK theme from supported Linux repositories, enable it for GTK apps in GNOME Tweaks, and see what the legacy theme can and cannot change.

How to Install and Set Up Plex on OpenMediaVault with Compose

How to Install and Set Up Plex on OpenMediaVault with Compose

The old OpenMediaVault Plex plugin is archived. Set up Plex on OMV 8 with OMV-Extras, the Compose plugin, persistent storage, and Plex’s official container.

How to Clean and Speed Up Ubuntu Safely

How to Clean and Speed Up Ubuntu Safely

Clean and speed up Ubuntu with safe APT cleanup, storage checks, and startup controls that help free space and troubleshoot a sluggish desktop.

How to Install the Hiri Email Client on Linux

How to Install the Hiri Email Client on Linux

Install Hiri on Linux with its Snap package or official tarball, add a desktop launcher, and check supported accounts plus a warning about Hiri’s old Snap release.

How to Get System Specifications for a Linux PC

How to Get System Specifications for a Linux PC

Use Fastfetch and built-in Linux commands to check your distro, kernel, CPU, memory, graphics, storage, and connected devices, then save a clear report.