Forgetting the root password can feel like being locked out of your own house, especially when you need administrative access to manage a Linux server or workstation. If you are searching for a reliable way to reset root password on Linux, you are not alone. This guide walks you through safe, proven methods to regain root access without reinstalling your operating system. Whether you use Ubuntu, CentOS, Debian, or Fedora, understanding how to reset root password on Linux is an essential skill for every system administrator and Linux enthusiast.
Why You Might Need to Reset Root Password on Linux
The root account is the most privileged user on a Linux system. It can install software, modify system configurations, and manage all user accounts. Because of this power, many Linux distributions disable direct root login by default and encourage the use of sudo for administrative tasks.
- You inherited a server from a former administrator who did not document the credentials.
- You changed the root password recently and forgot the new combination.
- An automated script or configuration error locked the root account.
- You need to perform critical system maintenance and sudo is not configured for your user account.
Regardless of the reason, regaining access is possible as long as you have physical or console access to the machine.
Prerequisites Before You Reset Root Password on Linux
Before attempting any recovery method, make sure you have the following:
- Physical or console access to the machine. Remote SSH access will not help if you cannot authenticate.
- Permission to reboot the system. Resetting the root password usually requires interrupting the boot process.
- A backup of important data, if possible. Although password recovery does not delete files, it is always wise to have a recent backup before making low-level system changes.
- Patience and attention to detail. A single typo in the bootloader or command line can prevent the system from starting correctly.
Method 1: Using GRUB to Reset Root Password on Linux
The most common way to reset root password on Linux involves editing the GRUB bootloader during startup. This method works on most major distributions, including Ubuntu, Debian, CentOS, and Fedora And that's really what it comes down to..
Step 1: Reboot and Access the GRUB Menu
Restart your computer. As soon as the system begins to boot, press and hold the Shift key (on BIOS systems) or press Esc repeatedly (on UEFI systems) to bring up the GRUB menu. If you see the Linux distribution logo instead of the menu, reboot and try again.
This changes depending on context. Keep that in mind.
Step 2: Edit the Boot Entry
Use the arrow keys to highlight the default kernel entry, then press e to edit it. You will see a screen with several lines of boot parameters.
Look for the line that starts with linux or linuxefi. It usually contains parameters such as root=UUID=..., ro, and quiet splash.
Step 3: Mount the Filesystem as Read-Write
By default, the root filesystem is mounted read-only (ro) during the initial boot stage. To change the password, you need write access But it adds up..
Find the ro parameter in the linux line and change it to rw. Then, append the following at the end of the same line:
init=/bin/bash
This tells the kernel to start a Bash shell instead of the usual init system, giving you a root prompt with a writable filesystem Simple as that..
Press Ctrl+X or F10 to boot with these temporary settings.
Step 4: Reset the Root Password
Once the system boots, you should see a root prompt that looks like this:
root@(none):/#
Run the following command to reset root password on Linux:
passwd root
You will be prompted to enter a new password twice. Choose a strong password that combines uppercase letters, lowercase letters, numbers, and symbols. After confirming the new password, you should see a message indicating that the password has been updated successfully.
Step 5: Reboot Normally
Before rebooting, it is good practice to remount the filesystem as read-only to ensure data integrity:
mount -o remount,ro /
Then restart the system:
exec /sbin/init
Or simply force a reboot using the hardware reset button if the command does not work. Once the system starts normally, you can log in as root using your new password Not complicated — just consistent..
Method 2: Using a Live USB/CD to Reset Root Password on Linux
If GRUB is protected by a password or if editing boot parameters does not work, you can use a live Linux USB or CD to reset root password on Linux. This method is especially useful for encrypted systems or servers with locked bootloaders The details matter here. Simple as that..
Step 1: Boot from the Live Media
Insert your live Ubuntu
USB or DVD installer in your machine, power it on, and interrupt the normal boot by holding Shift or pressing Esc to select the external drive from the boot menu. At the installer's GRUB screen, choose Try Ubuntu (or the equivalent "Try without installing" entry on your live media). Wait for the desktop to load, then open a terminal with Ctrl+Alt+T.
The live environment runs entirely in RAM, so your installed system is untouched. Everything from here on happens by mounting your real root filesystem and working inside it.
Step 2: Identify Your Root Partition
List the available block devices and filesystems:
lsblk -f
Look for the partition that holds your installed distribution. Plus, on a typical single-boot setup this is something like /dev/sda1 with an ext4 filesystem type. If you use LVM, the root device will appear under a mapper path such as /dev/ubuntu-vg/root.
sudo cryptsetup open /dev/sda3 cryptroot
Once unlocked, LVM and LUKS volumes usually appear automatically under /dev/mapper/ Not complicated — just consistent. No workaround needed..
Step 3: Mount the Filesystem and Enter the chroot
Create a mount point and attach your root partition:
sudo mount /dev/sda1 /mnt
Substitute your own device path. If your system uses a separate /boot or a UEFI system partition, mount those as well:
sudo mount /dev/sda2 /mnt/boot
sudo mount /dev/sda1 /mnt/boot/efi
A chroot needs access to the live environment's virtual filesystems, so bind them in before switching roots:
sudo mount --bind /dev /mnt/dev
sudo mount --bind /dev/pts /mnt/dev/pts
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo mount --bind /run /mnt/run
Then enter the installed system:
sudo chroot /mnt
Your prompt will change, and from this point on every command runs against your real installation rather than the live USB And that's really what it comes down to..
Step 4: Set the New Password
passwd root
Enter the new password twice. On Ubuntu and Debian, the root account is typically locked by default (! or * in
the /etc/shadow file). Running passwd root as shown above replaces that locked entry with a real password hash, so the account becomes usable for login and sudo escalation once you reboot into your normal system Less friction, more output..
If passwd refuses to run inside the chroot because the filesystem was mounted read-only, remount it with write access before trying again:
mount -o remount,rw /mnt
passwd root
Some administrators prefer not to tap into the root account at all. In that case, reset the password of your own user instead and rely on sudo:
passwd yourusername
Step 5: Exit the chroot and Reboot
Once the password is set, leave the chroot and cleanly unmount everything in reverse order. Unmounting without the bind mounts in place will otherwise leave stale references behind:
exit
sudo umount -R /mnt
The -R flag unmounts recursively, which is important because your chroot still has /dev, /proc, /sys, and the boot partitions attached underneath /mnt And that's really what it comes down to. Surprisingly effective..
If you unlocked a LUKS volume earlier, close it as well:
sudo cryptsetup close cryptroot
Now shut down the live environment, remove the USB or DVD, and power the machine back on:
sudo reboot
Let it boot normally from the internal drive. When the login prompt appears, authenticate as root with the new password, or log in as your regular user and confirm that sudo works.
Verifying the Change
After rebooting, a quick way to confirm the password is valid is:
su -
Enter the new root password when prompted. On the flip side, if you land in a root shell, the reset succeeded. Type exit to return to your normal account.
If login still fails, the most common causes are a stale cached credential, a filesystem that was mounted read-only during the change, or editing the wrong partition. Re-run the steps above and double-check that the device you mounted in Step 2 is actually the one holding your root filesystem.
Wrapping Up
Resetting a forgotten root password is a recovery procedure, not a normal daily operation. The live-media approach works precisely because it sidesteps the running system entirely: you boot an independent environment, mount the real filesystem, and change the password with full authority inside a chroot.
A few practical takeaways:
- Keep a bootable live USB on hand before you need it. Recovery is far less stressful when the tools are already available.
- If you use full-disk encryption, remember that unlocking LUKS requires the passphrase, so keep that separate from your account password.
- After regaining access, review how the password was lost. Repeated incidents usually point to a weak password-storage habit or a shared machine, and a password manager resolves both.
- Consider whether you actually need root login enabled. On Ubuntu and Debian, leaving root locked and using
sudois the safer default for everyday administration.
With the steps above you can regain control of almost any Linux system you have physical access to, from a basic desktop install to an encrypted server with a locked bootloader. Physical access always trumps software protection, which is exactly why disk encryption and secure boot matter: they protect the data even when someone can reset the password.
Counterintuitive, but true.