Practical Linux, Windows Server and cloud guides for IT pros.

How to Reset a Linux Root Password on Ubuntu, RHEL and Debian

A step-by-step root-password recovery guide for Ubuntu, RHEL and Debian, including the caveats that matter on modern systems.

Filed under

Published

Written by

Last updated

Featured image for How to Reset a Linux Root Password on Ubuntu, RHEL and Debian

TL;DR – Linux root password recovery

  • You need console access: Password recovery is easy once you can reach the bootloader, impossible if you cannot.
  • Ubuntu, RHEL and Debian differ: The reset path changes at the boot stage, not at the passwd stage.
  • RHEL usually needs extra care: If SELinux is enforcing, relabel after the reset if you used the rd.break path.
  • Cloud boxes are their own case: Provider console or rescue access often matters more than distro knowledge.

Start here: If you only need the older distro-specific walkthroughs, start with How to Reset a Lost Root Password in Linux or How to Change the Ubuntu Root Password. This page puts the Ubuntu, RHEL and Debian approaches side by side.

DistroWhenRecovery path
UbuntuLocal VM or console accessRecovery mode -> root shell -> mount -o remount,rw / -> passwd
RHELGRUB available at bootrd.break -> mount -o remount,rw /sysroot -> chroot /sysroot -> passwd
DebianGRUB edit or recovery shellsingle-user shell -> passwd -> reboot
Cloud VMLost SSH onlyUse provider console or rescue workflow first

At a command level, password recovery is not complicated. The complication is getting a writable root shell on the right system in the right state. That is why so many root-password guides feel longer than the command they are built around.

Diagram showing root-password recovery approaches for Ubuntu, RHEL and Debian

Step-by-step: reset the password on Ubuntu, RHEL, and Debian

The password change itself is short. The real job is getting a writable root shell on the right distribution. Use the distro-specific path below instead of mixing commands from different guides.

Ubuntu

  1. Reboot and open the GRUB menu. On many systems that means holding Shift or tapping Esc during boot.
  2. Choose Advanced options for Ubuntu, then a recovery-mode entry, then root to drop into a recovery shell.
  3. Remount the root filesystem read-write.
  4. Run passwd root. If the Ubuntu root account is intentionally locked, reset a sudo-capable user instead with passwd your-admin-user.
  5. Reboot normally and test the new credentials.
mount -o remount,rw /
passwd root
# or, on many Ubuntu systems, reset the admin user instead
passwd your-admin-user
reboot

RHEL and compatible systems

  1. At the GRUB screen, highlight the kernel entry and press e to edit it.
  2. Append rd.break to the kernel command line, then boot with Ctrl+x or F10.
  3. Remount /sysroot read-write and chroot into it.
  4. Run passwd root.
  5. Create /.autorelabel before rebooting so SELinux labels are repaired on the next boot.
mount -o remount,rw /sysroot
chroot /sysroot
passwd root
touch /.autorelabel
exit
exit

Debian

  1. Open the GRUB menu at boot and press e on the Debian entry.
  2. Find the line that starts with linux and append init=/bin/bash to the end of that line.
  3. Boot with Ctrl+x or F10 to land in a root shell.
  4. Remount the root filesystem read-write and run passwd root.
  5. Sync the filesystem and force a reboot.
mount -o remount,rw /
passwd root
sync
reboot -f

What this guide actually covers

This guide is for situations where you own the machine or VM, can reach GRUB or a recovery console, and need to reset a lost or unknown root password. It is not a bypass trick for managed hosting. If you only lost SSH access but still have another privileged user, that is a simpler problem.

Ubuntu: recovery mode is the clean path

# From the recovery root shell
mount -o remount,rw /
passwd root
reboot

On Ubuntu, the recovery menu is usually the least dramatic option. Drop to the root shell, remount the root filesystem read-write, reset the password, then reboot. If you normally administer the box with sudo rather than root, consider whether you really need to enable direct root login afterwards.

RHEL: use rd.break and remember SELinux

# After booting with rd.break
mount -o remount,rw /sysroot
chroot /sysroot
passwd root
touch /.autorelabel
exit
reboot

RHEL is the one that catches people because the reset often happens from an initramfs shell rather than a friendly recovery menu. If SELinux is enforcing and you skip the relabel step after changing the password from that environment, you can create a second login problem.

Debian: same goal, simpler boot semantics

# From a Debian root shell
mount -o remount,rw /
passwd root
sync
reboot -f

Debian recovery tends to be conceptually closer to Ubuntu than to RHEL. The pattern is still the same: get a root shell, remount read-write if necessary, reset the password, reboot cleanly.

The caveats that matter in real environments

  • Encrypted disks: Recovery still depends on being able to unlock the volume at boot.
  • Cloud VMs: You may need hypervisor console access, not just SSH.
  • Modern admin habits: Many teams should reset a privileged sudo-capable user instead of leaning on the root account.
  • Change windows: If the machine is critical, capture the steps before you reboot into recovery.

Once access is restored, the next job should usually be hardening, not celebration. Pair this with Linux SSH Hardening Checklist for Small Servers and Home Labs if the box is remotely accessible.


Related next steps

Elsewhere On TurboGeek:  Ubuntu 26.04 LTS Security Changes That Actually Matter

Leave a Reply

Your email address will not be published. Required fields are marked *

Find more on the site

Keep reading by topic.

If this post was useful, the fastest way to keep going is to pick the topic you work in most often.

Want another useful post?

Browse the latest posts, or support TurboGeek if the site saves you time regularly.

Translate »