CentOS7----Linux Root forgotten, enter rescue mode to change password (two methods!)

Please follow the code provided below to modify

(The results of the personal test below!)

Boot the Linux system to enter the boot screen, select: CentOS Linux(3.10.0-693.e17.x86_64)7 (Core), press the letter "E" key to enter the Linux kernel mode for editing.

 

After entering the Linux kernel mode, find the line starting with Linux16, enter at the end: rd.break, then hold down Ctrl+x to boot to rescue mode

 code show as below:

mount  -o  remount   rw  /sysroot

chroot   /sysroot

LONG=C

passwd

touch /.autorelabel makes SELinux take effect. If it is not executed, the modified password will not take effect.

exit

Remember: you need to exit the sh-4.2# mode before you can use the reboot command to restart

 

 

The second method:

 

Find a line of Linux16, find the ro character, and modify it to: rw init=/sysroot/bin/bash , press Ctrl+x to enter rescue mode

 

 code show as below:

chroot   /sysroot

LANG = en

passwd 

touch /.autorelabel makes SELinux take effect. If it is not executed, the modified password will not take effect.

exit 

reboot

 

 The above are two methods recorded when learning Linux. If there are any inaccuracies, please contact below.

  E-Mail:[email protected]

  QQ:1958344794

 Baidu search: http://www.cnblogs.com/DaniuUnixChina/

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324769921&siteId=291194637