Get the App
SLTechnology News&Howtos  ›  Servers  › 

CentOS 7 forgot the root password modification method

Shulou Source: shulou.com Published: 2022-06-02 16:32:37 11月03日 Update

The root password recovery of CentOS 7 is different from that of 5Power6, because 7 uses GRUB2 to start, and it is impossible to reset the root password through single-user mode if you forget your password. Here are two tips to help you easily reset your root password.

The first move to amend the Dafa

Press "esc" to turn on the computer

Select "CentOS Linux (3.10.0-327.)" and press the "e" key to enter

Move the cursor to the line at the beginning of "linux16" and find "ro" instead of "rw init=sysroot/bin/sh"

Press "Ctrl+x" to execute

Enter "chroot / sysroot" after entering

Enter "passwd"

Enter the new password twice according to the prompt

Enter "touch / .autorelabel" to update system information

Enter exit or press Ctrl+d to exit

Enter "reboot" to restart

The second move to amend the Dafa

Press "esc" to turn on the computer

Select "CentOS Linux (3.10.0-327.)" and press the "e" key to enter

Move the cursor to the line at the beginning of "linux16" and add "init=/bin/bash" at the end of the line

Press "Ctrl+x" to execute

Mount the file system to be writable

Enter "passwd"

Enter the new password twice according to the prompt

Enter "touch / .autorelabel" to update system information

Enter "exec / sbin/init" to start the system normally

Tags: Input password system Dafa information cursor beginning new secret prompt update move select different in line two file different mode single user Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Redmi Shulou Technology MariaDB Apple