Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

How to reset a root or administrator password in Ubuntu 24.04

Distinguish Ubuntu’s locked root account from your sudo password, then use an existing administrator or recovery mode on an authorized machine.

Table of Contents

Ubuntu normally locks the root password and uses sudo for administrative commands. The password sudo requests is usually your own user's password, not a separate root password. Before resetting anything, identify which account you need to recover.

Use these procedures only on a machine you own or administer. Encrypted disks still require their unlock credentials, and a managed or cloud-hosted machine may require its administrator's recovery process.

If another administrator can sign in

For a forgotten local user's password, an authorized administrator can run the following, replacing username with the actual login name:

sudo passwd username

If the root account was deliberately given a password and you specifically need to replace it, use:

sudo passwd root

How to reset forgotten root password in Ubuntu 24.04 Picture 1

Authenticate with the administrator's sudo password if requested, then type the new target password twice. Terminal password prompts normally show no characters while typing. Read which account the command targets before confirming.

How to reset forgotten root password in Ubuntu 24.04 Picture 2

How to reset forgotten root password in Ubuntu 24.04 Picture 3

Setting a root password enables password authentication for that account; it is not needed for normal Ubuntu administration. Ubuntu's RootSudo explanation describes the default model.

If no local administrator can sign in

On an authorized local installation, Ubuntu's recovery environment may allow a password reset. Availability depends on bootloader protection, disk encryption and system configuration.

  1. Restart and display the GRUB menu. On many BIOS systems, holding Shift helps; on UEFI systems, tapping Esc may display it. Timing varies.
  2. Choose Advanced options for Ubuntu, then an entry marked recovery mode.
  3. Select the option to drop to a root shell. If it requires credentials you do not have, use the documented administrator recovery route instead.
  4. If the root filesystem is read-only, remount it read/write:
mount -o remount,rw /

How to reset forgotten root password in Ubuntu 24.04 Picture 4

The following screenshots illustrate GRUB and an alternative temporary kernel-edit workflow. For the standard recovery route above, use the recovery entry; do not copy a different computer's kernel path or replace its entire boot command.

How to reset forgotten root password in Ubuntu 24.04 Picture 5 How to reset forgotten root password in Ubuntu 24.04 Picture 6 How to reset forgotten root password in Ubuntu 24.04 Picture 7

A command-line shell started with a temporary init=/bin/bash boot edit is not the same environment as the normal recovery menu. Shutdown commands and available services can differ, so avoid mixing instructions between the two methods.

Reset the intended account

In the recovery root shell, reset your normal administrative user's password with:

passwd username

Only use passwd root when the explicit goal is changing a deliberately enabled root password. Running passwd without a username from a root shell changes root, which will not fix a forgotten ordinary user's login.

How to reset forgotten root password in Ubuntu 24.04 Picture 8

How to reset forgotten root password in Ubuntu 24.04 Picture 9

Enter the replacement twice and check for the successful-update message. If an authentication-token error appears, check whether the filesystem is writable and whether storage is full or reporting errors; do not repeatedly change unrelated files.

How to reset forgotten root password in Ubuntu 24.04 Picture 10

How to reset forgotten root password in Ubuntu 24.04 Picture 11

After a successful change, run sync, exit the recovery shell and use the recovery menu's normal boot option. Test the intended user's login after restarting.

Important recovery limits

A login-password reset does not recover a lost disk-encryption passphrase, decrypt an encrypted home automatically or necessarily unlock a keyring protected by the old password. Preserve backups and investigate those prompts separately.

The Ubuntu recovery-mode guide and lost-password documentation provide the applicable recovery context. Do not change SSH root-login policies or permanently weaken boot protection merely to regain a normal local account.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.