Linux retrieve root password (CentOS7.6)

Linux study notes: for review~~~~

First, start the system, enter the startup interface, and press "e" in the interface to enter the editing interface. as shown in the picture

Enter the editing interface, use the up and down keys on the keyboard to move the cursor down, find the number of lines starting with "Linux16", and enter: init=/bin/sh at the end of the line. as shown in the picture

Then, after the input is complete, directly press the shortcut key: Ctrl+x to enter single-user mode .

Then, enter: mount -o remount,rw / (note: there are spaces between each word) at the position where the cursor is blinking, and press the Enter key (Enter) on the keyboard after completion. as shown in the picture

 Enter: passwd at the end of the new line, and press the Enter key on the keyboard after completion. Enter the password, and then confirm the password again ( reminder : the length of the password should be more than 8 characters , but not necessary ), after the password is changed successfully, the style of passwd..... will be displayed, indicating that the password has been changed successfully

Then, enter: touch /.autorelabel (note: there is a space after touch and /) at the position where the mouse is blinking (in the last line), press the Enter key (Enter) on the keyboard after completion, and continue at the position where the cursor is blinking , input: exec /sbin/init (note: there is a space behind exec and /), press the Enter key (Enter) on the keyboard after completion, and wait for the system to automatically change the password (reminder: this process may take a long time, wait patiently ) , after the completion, the system will automatically restart, and the new password will take effect

Guess you like

Origin blog.csdn.net/qq_61544409/article/details/126084588