How to Repair and Rescue Debian / Fedora Linux without Root Password

Most Linux now requires root account password to get into recovery or rescue mode. What if PC does not boot, or you forgot the password?

Forgot user password or Linux refuse to boot after incorrect configuration? Well, you can rescue even without remembering the root password.

Most Linux systems support booting the recovery and rescue mode. However, most of them except Ubuntu now require the root password authentication. If you don’t remember it or root is even not enabled, /bin/bash or live USB installer may help!

Requirements:

This tutorial is to repair Linux machine (e.g., Debian, Fedora, CentOS, and Ubuntu) with physical access. Remote servers are not supported since you can not operate while booting.

If the file system is encrypted during installation, you have to remember the password. Or, no one can help!

Boot /bin/bash without any password authentication:

If your system still boots though you can not log in, then follow the steps below to rescue.

1.) Firstly, boot or reboot your machine and press Esc key on keyboard to show the Grub menu. When you’re at boot menu, press e to edit the menu entry.

2.) Next, use the arrow keys on keyboard to move the mouse cursor. Go to the end of line started with “linux”. It’s usually a long line display in multiple lines ‘\’ separator.

In the end of that line, enter a space and then input init=/bin/bash

3.) After that, hit Ctrl+X on keyboard to bring you to the bash screen. There, remount file system with read & write access:

mount -o rw,remount /

Now, you may reset user password, restore incorrect configuration, or do anything else to your file system! When done, either use “exec /sbin/init” command to continue booting Linux, or run ‘/sbin/reboot -f‘ to restart.

If you going to rescue user password, remember to restore the SELinux context and permissions via touch /.autorelabel command after running passwd USER_NAME.

Rescue via Live USB:

If somehow /bin/bash does not work or even your computer does not boot, a live USB installer is the final way to rescue.

First of all, you have to create a live USB installer for Ubuntu, Fedora, Debian, Linux Mint, or any other Linux with live system. Linux Mint is recommended for booting issue, since it has ‘Boot Repair’ pre-installed..

Next, boot the live USB on your computer. For boot-loader issue, open boot-repair and click “Recommended Repair”.

Find out Linux partition:

Before getting start, you need to find out the Linux file system. Open terminal from start menu, and run command:

sudo fdisk -l

This command tells all available disks and partitions. In the case (see picture below) /dev/sda3 is my Linux file partition. And /dev/sda1 is the EFI partition.

Mount the file system and rescue:

Now, in terminal mount the file system into /mnt directory by running command:

sudo mount /dev/sda3 /mnt

And mount the EFI partition via command (skip this if you don’t enabled EFI secure boot):

sudo mount /dev/sda1 /mnt/boot/efi

Finally, go to /mnt directory and run the chroot command:

cd /mnt && sudo /usr/sbin/chroot /mnt

Now you’ll see the command prompt changes to “[email protected]:\“, which means you’re working as the root user of the Linux system. Finally, you may reset root password via passwd, restore incorrect configuration or backup your data.

When everything’s done, un-mount via sudo umount /mnt command if required, and reboot.

Merilyn Ne
Hi, I'm Merilyn Ne, a computer geek working on Ubuntu Linux for many years and would like to write useful tips for beginners. Forgive me for language mistakes. I'm not a native speaker of English.