# Breaking the Root Password

So, you've probably forgotten the root password to your system and thought that it was all over, and you have to make another one. Fortunately, there is a way to recover your system even when you've lost the password (for future reference, write it down somewhere secure): by ***Breaking The Root Password.***

### Lab Environment

*   **Virtual Machine -** [VMware Workstation Pro](https://www.techspot.com/downloads/189-vmware-workstation-for-windows.html)
    
*   **Operating System (ISO Image)** - [Red Hat Enterprise Linux 10.2 (DVD ISO)](https://developers.redhat.com/products/rhel/download#downloadsbyrelease)
    

### Step-by-Step Process

1.) First, while booting your system, interrupt GRUB by pressing any key. You should then see this screen:

![](https://cdn.hashnode.com/uploads/covers/6aab15fc963009129466d4b7/9a51398f-aac4-4b05-a7c7-093b9efa3b5a.png align="center")

*#This is the GRUB boot menu. GRUB stands for Grand Unified Bootloader, and it's the program that runs before Linux starts; its main job is to load the Linux kernel and begin the boot process.*

2.) Go to the second option (the one that has the word rescue) and press e to edit the command. Doing so should bring you to this menu:

![](https://cdn.hashnode.com/uploads/covers/6aab15fc963009129466d4b7/4403babc-20d7-449e-9555-516288588f61.png align="center")

*#This is the GRUB edit screen; it displays the commands used to boot the system. It can be used for troubleshooting and recovering your system.*

3.) Edit the end of the line that starts with "linux*"* and type *rd.break*, then press Ctrl+X to boot into the chroot environment (when on the linux line, press Ctrl+E to get to the end faster). This is basically the "Pre-boot" of the system, designed so that you can change something before you actually boot your system.

![](https://cdn.hashnode.com/uploads/covers/6aab15fc963009129466d4b7/1c7b7c95-0160-4dfd-917b-203204633b53.png align="center")

![](https://cdn.hashnode.com/uploads/covers/6aab15fc963009129466d4b7/55672ba9-7e1c-482b-849e-274d74167b69.png align="center")

4.) Right now it's read-only; you cannot modify anything. To modify something, you must change it from read-only to read-write by mounting the system to /sysroot using the command *mount -o remount,rw /sysroot*.

![](https://cdn.hashnode.com/uploads/covers/6aab15fc963009129466d4b7/6491a7bb-f623-48ba-846d-3e054ff7b40c.png align="center")

*#mount -o stands for mount options; the option you are choosing in this case is remounting /sysroot to read-write.*

5.) Use the command *chroot /sysroot* and (on a newline) *passwd root* to change the root password (change it to anything you want, but just be sure to remember it this time :) ).

![](https://cdn.hashnode.com/uploads/covers/6aab15fc963009129466d4b7/656ce9d9-4635-4e19-86ae-1f2c76f10a33.png align="center")

6.) Now this is the most important part: create a hidden file */.autorelabel* by using the command *touch /.autorelabel* (WARNING: if you misspell "autorelabel" you can potentially lock yourself out of your system forever).

![](https://cdn.hashnode.com/uploads/covers/6aab15fc963009129466d4b7/9f28a8d7-8a5e-43b0-8a69-98111e39791f.png align="center")

*#You can create a hidden file by putting a ' . ' before the file name (i.e touch /.hiddenfile).*

7.) Now exit, and you've successfully broken the root password.

![](https://cdn.hashnode.com/uploads/covers/6aab15fc963009129466d4b7/618320dd-3f5c-46cb-aa62-1d108d38c9eb.png align="center")

![](https://cdn.hashnode.com/uploads/covers/6aab15fc963009129466d4b7/2c594a53-537f-4996-ba08-57017adb5976.png align="center")

## Closing Remarks

Although this was a fairly straightforward process, understanding how to break the root password is an important skill for Linux administrators because it provides a way to recover a system even when access is lost. Thank you for joining me on this learning journey, and make sure, for future practice, that your passwords are either memorized or securely documented.
