How to Enter Single User Mode and Reset Root Password in Linux 6 and 7

How to Enter Single User Mode and Reset Root Password in Linux 6 and 7Introduction:When I first started working, a leader from another department often forgot the root password for his Linux testing environment and would ask me for help to bypass it. I could easily enter single user mode, reset the password, and reboot in about a minute. After leaving that company, I hardly used single user mode again. Recently, I encountered a situation with the Kylin operating system where I forgot the root password and found that the method to enter single user mode differs significantly from Linux 5 and 6, but is quite similar to Linux 7. This article documents the methods for entering single user mode in Linux 6 and 7.

Single User Mode Introduction:

Single user mode in Linux is a powerful system maintenance and recovery environment. Its core function is to allow administrators to access a minimal system environment with the highest privileges (root) without providing a password. It is primarily used for resolving severe system failures, performing critical maintenance, or resetting passwords.

Single user mode profoundly reflects the design philosophy of Linux/Unix: individuals with physical access are considered trusted administrators. This is the source of its powerful recovery capabilities, but also a potential security risk.

Among them, entering single user mode in Linux 6 is very simple, while in Linux 7 it differs significantly.

Environment Description:

Linux 6: Red Hat Linux 6.5
Linux 7: Oracle Linux 7.9

How to Enter Single User Mode and Reset Root Password in Linux 6 and 7

Entering Single User Mode in Linux 6:

How to Enter Single User Mode and Reset Root Password in Linux 6 and 7

During the boot process, you will see the boot menu. Use the up and down arrow keys to select the system for which you forgot the password, then press “e” to edit. The countdown is 5 seconds… Be quick!

How to Enter Single User Mode and Reset Root Password in Linux 6 and 7

Press e

How to Enter Single User Mode and Reset Root Password in Linux 6 and 7

Then press e, use the up and down keys to navigate to the second line.

How to Enter Single User Mode and Reset Root Password in Linux 6 and 7

Then press e

How to Enter Single User Mode and Reset Root Password in Linux 6 and 7

At the end of the line containing rhgb quiet, add a space and type single, or directly input the number 1 and press Enter, as shown below:

How to Enter Single User Mode and Reset Root Password in Linux 6 and 7

After pressing Enter, return to this interface.

How to Enter Single User Mode and Reset Root Password in Linux 6 and 7

Press b to reboot the system, which will automatically enter single user mode.

How to Enter Single User Mode and Reset Root Password in Linux 6 and 7

You can perform some routine checks.

How to Enter Single User Mode and Reset Root Password in Linux 6 and 7

You can also reset the root password.

How to Enter Single User Mode and Reset Root Password in Linux 6 and 7

Reboot the system.

How to Enter Single User Mode and Reset Root Password in Linux 6 and 7

Use the new root password to log in successfully.

How to Enter Single User Mode and Reset Root Password in Linux 6 and 7How to Enter Single User Mode and Reset Root Password in Linux 6 and 7

Entering Single User Mode in Linux 7:

How to Enter Single User Mode and Reset Root Password in Linux 6 and 7How to Enter Single User Mode and Reset Root Password in Linux 6 and 7How to Enter Single User Mode and Reset Root Password in Linux 6 and 7Reboot the system.How to Enter Single User Mode and Reset Root Password in Linux 6 and 7Press eHow to Enter Single User Mode and Reset Root Password in Linux 6 and 7

Use the down arrow key to scroll down and find the line starting with linux 16:

Change ro to rw, and add space and init=/sysroot/bin/sh

Before modification:

How to Enter Single User Mode and Reset Root Password in Linux 6 and 7

After modification:

How to Enter Single User Mode and Reset Root Password in Linux 6 and 7

Press Ctrl+x

How to Enter Single User Mode and Reset Root Password in Linux 6 and 7Input: chroot /sysroot/How to Enter Single User Mode and Reset Root Password in Linux 6 and 7

Modify the root password: the Chinese characters are garbled, but it does not affect the password reset.

How to Enter Single User Mode and Reset Root Password in Linux 6 and 7

Create a file:

touch /.autorelabel

How to Enter Single User Mode and Reset Root Password in Linux 6 and 7

Exit and reboot the system:

exit

Reboot the system:

reboot

How to Enter Single User Mode and Reset Root Password in Linux 6 and 7How to Enter Single User Mode and Reset Root Password in Linux 6 and 7How to Enter Single User Mode and Reset Root Password in Linux 6 and 7Log in with the new password successfully:How to Enter Single User Mode and Reset Root Password in Linux 6 and 7—End—Thank you for following my public account “IT Xiao Chen”How to Enter Single User Mode and Reset Root Password in Linux 6 and 7

Leave a Comment