Skip to content

How to break root password in Linux

How to break root password in Linux

Reading Time: 3 minutes

This tutorial will guide you on How to break root password in Linux. If you’re having trouble with a Linux system or need to recover a password you need to reset or break root account password. You may forget root password or your sudoers has access and there is no other way to fix then we recommend you to break root password.

If you’re having trouble with a Linux system or need to recover a password, I recommend taking legitimate and ethical steps however easiest approach is reset root password by entering into single usermode. We hope this tutorial How to break root password in Linux will guide you to achieve the same.

Password Recovery: If you’ve forgotten a password for a user account on a Linux system, you should try to recover it using legitimate methods. Some distributions offer password recovery options during the boot process.

  1. Reset Password: If you have root access to the system, you can reset passwords for user accounts, including the root account, using the passwd command. This should be done within the proper context and with the necessary permissions.
  2. Single-User Mode: If you have physical access to the machine, you might be able to gain access to the root account by booting into single-user mode. However, this method requires valid credentials for the GRUB bootloader.
  3. Live CD/USB: You can boot the system using a Linux Live CD or USB, mount the system’s root partition, and then edit the password file to reset or change the password. This should be done responsibly and only on systems you have permission to access.

How to break root password in Linux

Please follow below steps:

Boot the server (Power Reset)

Interrupt on splash screen to get into single user mode
Note: You can interrupt by using arrow key and navigate to latest Kernel then press “e” to edit

Note: The splash screen of a Linux system, which is the first screen you see when the operating system is booting up, is fully customizable. Behind the bootsplash screen is textual output, detailing the startup process of the system.
Please follow the complete tutorial ” How to break root password in Linux “

Add “rd.break” in /vmlinuz

Add “rd.break” in /vmlinuz line and then press “control+x” to reboot linux system.
Once system is booted it should enter into single user mode and you can validate the same using below steps.

Above steps will mount your root file system into “read only (RO)” mode. You can validate this by running the command below. Also, the output below clearly shows that you are in “Emergency Mode”.

$mount | grep root

This will show root File system is in RO mode

Remount root filesystem

$mount -o remount,rw /sysroot

Root File system will be mounted as read/write mode as we used option “rw” in above command. You can validate the again by running below command.

$mount | grep root
This will show root File system is in RW mode

Run the below command to change the environment, commonly known as “jailed directory” or “chroot jail” :

What is Jailed Directory

In the context of Linux, a “jailed directory” often refers to a setup where a user or process is restricted to a specific directory or environment, preventing them from accessing other parts of the system. This concept is often implemented using technologies like chroot or more advanced solutions like containers (e.g., Docker) or virtualization (e.g., virtual machines).

$ chroot /sysroot
Note: start a new shell in such a way that for that shell the /sysroot directory will appear as /

$ touch /.autorelabel

Reset root password

$ passwd root
Enter New password twice.

Reboot Server

$ reboot -f

Create autorelabel hidden file

$ touch /.autorelabel
Note : This command creates a hidden file named .autorelabel under the root directory. On the next boot, the SELinux subsystem will detect this file, and then relabel all of the files on that system with the correct SELinux contexts. On large disks, this process can take a good amount of time.

Once system is booted, you can ssh to your server with updated root password.

You can also follow tutorial how to login to linux system.
Redhat has also explained in detail on Single User Mode.

Concusion: If you have any question on “How to break root password in Linux ” tutorial, Please reach out to us.


Leave a Reply

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