Centos forget the root password, how do?

1 to reset the administrator password centos7

1.1 centos7 administrator password reset steps

  1) After rebooting the server, the grub menu interface , according to the message interface display, according to e into edit mode. Note: SELinux is turned on, the operation to reset the password only a little difference.

  2) move the cursor to the last, found linux16 line, and moves the cursor end of that line, is added at the end of the init = / bin / the bash , then hold down the C TRL + X single-user mode.

  3) into the interface, the input shown in FIG mount -o remount, rw /  re-write permissions can be mounted in / root file system, and enter passwd root  reset the administrator password; performed last exec / sbin / init restart operation The system can be.

Reset the administrator password at 1.2 selinux open case 

  2) In the above second step, the end of the line where the input linux16 enforcing the init = 0 = / bin / the bash , and then while holding down  the Ctrl + X  , skip SELinux, in single-user mode access to the system, other steps are the the same.

1.3 Summary

  1) centos7 unable to determine whether to open the case selinux, the need to execute the following command to reset the Super Administrator password in single-user mode.

enforcing = 0 init = / bin / bash # <== This content added in single-user mode where the end of the line linux16, if selinux is OFF confirmation can be omitted enforcing = 0
shell> mount -o remount, rw / # <== re-write permissions can be mounted to the root file system, the default single-user mode is read-only
shell> passwd root # <== super administrator password reset
shell> touch /.autorelabel # <== If the above command is not added to the first enforcing = 0, all related files need to perform this synchronization command selinux security context, the system in the relabeled After reset the password
shell> exec / sbin / init # <== reboot the system, you can not use other commands to restart

2 administrator password reset centos6  

2.1 centos6 administrator password reset steps

  1) After system restart, according to e into the GNU GRUB menu interface, and select the second item , continue to e .

 

 

  2) At the end of the new interface, the input single or a number 1 , then the carriage return to the previous screen. 

 

  3) In this interface, continue to select the second item , and then press B , i.e., can be a single-user mode operating system

 

  4) Input the passwd the root , password reset and reboot the system, reset the password to complete all the steps. 

 

 

Guess you like

Origin www.cnblogs.com/blog-tim/p/11900658.html