How to Change or Reset the Root Password on Ubuntu 26.04

Share

To change the root password on Ubuntu, run sudo passwd root from an administrator account. If you have lost administrator access, use the recovery path below to reset the account you actually need.

Ubuntu normally locks the root password and uses your own account for administrative tasks through sudo. This guide covers Ubuntu 26.04, 24.04 and 22.04, including recovery limitations and checks after a reset. If you get stuck, leave a comment or contact us.

Before you begin

Working administrator account: Use the terminal method. The sudo prompt normally asks for your own password.

No administrator access: You need the computer keyboard and display, or a virtual machine or provider console. Recovery requires a restart and interrupts running work.

Encrypted disk: Your Ubuntu login password and the disk unlock credentials are different. Traditional LUKS encryption usually needs a disk passphrase. Some supported Ubuntu installations use TPM-backed encryption and unlock automatically, but may request a recovery key. Resetting a login or root password cannot bypass disk encryption.

Choose the Right Password to Change

If you forgot the password you type to sign in to Ubuntu or approve sudo commands, reset your user account. That is different from the root account. If your own password still works and you only want to change it, run:

Terminal
passwd

If you specifically need a separate root password, use the next section. Setting one for the first time enables root password authentication; it is unnecessary for most administrative tasks. A temporary root shell can be opened with sudo -i instead.

Change or Set the Root Password with sudo

Step 1: Check the root password status

Open Terminal and check the account:

Terminal
sudo passwd -S root

The second field is L for a locked password, P for a usable password, or NP for no password. The remaining fields describe password aging. A status check does not prove that a particular password works or that SSH permits it.

Step 2: Set the password

Continue only if you need root password authentication. On a default installation this changes root from locked to usable.

Terminal
sudo passwd root

If sudo asks, enter your own administrator password first. Then enter the new root password twice. No characters appear while you type. A successful change ends with passwd: password updated successfully. Choose a strong, unique password.

Step 3: Check the result

Check the status again:

Terminal
sudo passwd -S root

The second field should now be P. If you need to test a local root login, run su -, enter the new root password, and type exit to leave. A server can apply additional login policies.

Reset a Forgotten Password in Recovery Mode

Use this path when you cannot use an administrator account. GRUB is the boot menu that starts Ubuntu. Recovery mode can provide a root shell, but its prompts and availability depend on the installation.

Step 1: Open the recovery menu
  1. Restart the machine. Save work first if you can.
  2. As the manufacturer logo disappears, hold Shift on many legacy BIOS systems or tap Esc repeatedly on many UEFI systems to show GRUB. Timing varies; if Ubuntu starts normally, restart and try earlier. In a VM, click inside its console first.
  3. Use the arrow keys to highlight Advanced options for Ubuntu and press Enter. Select a kernel entry ending in (recovery mode) and press Enter again.
  4. In the recovery menu, use the arrow keys to choose root – Drop to root shell prompt and press Enter. Follow the prompt shown. Menu names and appearance can vary by Ubuntu version and configuration.

If asked for a root password you do not know, see the next section. Do not assume Enter will always open a shell.

Step 2: Make the root filesystem writable

At the recovery root prompt, remount the installed root filesystem and check its options:

Recovery shell
mount -o remount,rw /
findmnt -no OPTIONS /

Look for rw as a comma-separated option. Other options and their order may differ. If remounting fails or the output still includes ro, stop and investigate the filesystem before changing a password.

Step 3: Reset the account you need

To reset an intentionally enabled root account, run:

Recovery shell
passwd root

To recover a normal administrator account instead, replace yourusername with its actual local login name:

Recovery shell
passwd yourusername

If you do not remember the login name, ls /home can offer a clue, but home directory names are not a complete account list. getent passwd lists account records; identify the intended local account before making changes. Enter and confirm the new password when prompted. The old password is not required from a root shell.

Step 4: Restart and verify

After the success message, restart:

Recovery shell
reboot

Sign in as the recovered user. If it should have administrator rights, run sudo -v and enter that user’s new password when asked. If the account still lacks permission, consult an administrator or your system’s access policy; a password reset does not grant sudo rights.

Optional: Restore a local administrator to the sudo group

Only if you administer this machine, have identified the correct local account, and know it should be an administrator, run the following from the recovery root shell before rebooting. This grants administrative access.

Recovery shell
usermod -aG sudo yourusername

Replace the name first. After restarting and signing in, id -nG shows the current user’s groups. Group membership and the configured sudo policy both affect access.

If Recovery Mode Asks for the Root Password

The recovery environment may request the root password before giving you a privileged shell. Ubuntu normally locks root’s password by default, but a password set later can be required here. If you know it, enter the root password rather than your normal user password. Another working administrator account can run sudo passwd root from its normal session. If no administrator account is available, use your provider’s documented rescue process or an Ubuntu live USB. Losing all administrator access can make recovery more complicated.

Live USB recovery depends on the actual disk layout, encryption, and whether the system uses LVM or multiple filesystems. On some TPM-backed systems, changed boot settings or a different recovery environment may require a recovery key. Have the relevant disk passphrase or recovery key available before changing boot settings. Identify and unlock the correct installed system before mounting it. Do not run chroot commands against a guessed device. See Ubuntu’s live media recovery guide; it is an older community reference, so check its steps against your installation.

Check and Secure Access After Recovery

For routine administration, prefer your own account with sudo. If you no longer need root password login, lock the root password after confirming a separate administrator account works:

Terminal
sudo passwd -l root
sudo passwd -S root

The status should show L. Locking preserves the existing password hash and disables password authentication for that account; it does not remove SSH keys or stop other authentication methods. Unlocking later can restore the old password, so use a new password if it may have been compromised.

A root password does not by itself permit root SSH login. SSH has its own configuration and authentication rules. On a system with OpenSSH server installed, inspect its effective default setting:

Terminal
sudo sshd -T | grep '^permitrootlogin '

For example, no denies root SSH login and prohibit-password disallows password authentication for root. Other settings, including Match rules and keys, may affect a particular connection. Keep your existing administrator session open while reviewing remote access.

Troubleshooting

GRUB or recovery mode is missing

Try the boot key earlier and check your firmware or hypervisor console instructions. If recovery mode is unavailable, another administrator account can reset a local account password. Cloud images and some customized installations use a different boot process: use the provider’s console or rescue tools, or an Ubuntu live USB where appropriate. SSH alone cannot show the boot menu.

Authentication token manipulation error

A read-only root filesystem, lack of free space, or filesystem errors can cause this message. At the recovery shell, check the root mount and its free space:

Recovery shell
findmnt /
df -h /

In the findmnt options, ro means read-only and rw means writable. In df, check the Available and Use% columns; a full filesystem needs space freed before retrying. If the filesystem has errors, investigate and repair the underlying problem safely. Changing file permissions alone does not repair it.

The password reset did not restore my login

Check which account you changed. passwd root in a root recovery shell changes root; passwd yourusername changes the named local user after you replace the placeholder. From a working administrator session, use sudo passwd yourusername to reset that user. Sign in as that user to test its password. Setting a root password does not restore sudo membership.

The new password works but stored secrets do not unlock

Resetting a login password outside the normal session may leave the desktop keyring protected by the old password. Encrypted home directories may also require their original encryption credentials. Preserve any old password or recovery key you still have; do not delete encrypted data or keyrings to fix a prompt without understanding the consequences.

The encrypted disk cannot be unlocked

A login password reset does not recover a lost disk passphrase or encryption key. Use your saved disk recovery method or contact the system administrator. TPM-backed encryption may unlock automatically on a normal boot and request a recovery key after a system change.

Frequently Asked Questions

What is the default root password on Ubuntu?

Ubuntu normally installs root with its password locked. There is no default root password to look up; authorized users perform administrative work with sudo.

Does resetting root change my normal login password?

No. Root and your normal user are separate accounts. Reset the account you actually need to use.

Can I reset the root password without the old one?

An authorized sudo administrator can set a new root password without entering the old root password. Recovery options depend on console access, encryption and system configuration.

Can I use sudo while root is locked?

Yes. An authorized user can use sudo with their own credentials even when the root password is locked.

Does locking root block SSH keys?

No. Locking the password alone does not remove authorized keys or necessarily prevent other authentication methods. Review the SSH configuration and root keys separately.

Does resetting my Ubuntu password unlock an encrypted disk?

No. Disk encryption uses its own unlock mechanism. Keep the disk passphrase or recovery key available when it is required.

Related guides: Enable or disable the root account · Use sudo on Ubuntu · Linux security commands