centos7 Forgot your password solution

For many reasons, the least recently used his computer in the virtual machine, the feeling still can not give up learning, to learn on the virtual machine, always find the password wrong, I looked for information to resolve. Under special record, note: I use centos7 version, other versions forget your password method is not the same.

Centos after entering the interface is shown below:
Here Insert Picture Description
if it will be carefully noted that the last two rows in the interface prompt: Press "e" key to edit the selected entry, or press the "c" key to pop up corrand prompt, the selected entry in the automatically 4s start up.

Then we press E, enter the edit mode, as shown below:
Here Insert Picture Description
There are two ways to reset the password:
first:

  1. After entering the editing mode key is pressed until the last, is added after the 'quiet' words: init = / bin / sh
  2. Press Ctrl-x Save and Exit
  3. Mount the file system as writable mode: mount -o remount, rw /
  4. Execute passwd command: passwd root, change the root password, the password to enter the password twice asked twice to be consistent.
  5. If before the system is enabled selinux, you must execute the following command, otherwise the system will not start properly: touch /.autorelabel. Then execute the command exec / sbin / init to start normally, or with the command exec / sbin / reboot restart on OK. If the selinux not enabled to boot directly off the line

The second:

  1. After entering the editing mode key is pressed until the last, is added after the 'quiet' words: init = / bin / sh, to rw and ro
  2. Press Ctrl-x Save and Exit
  3. Execute passwd command: passwd root, change the root password, the password to enter the password twice asked twice to be consistent.
  4. If before the system is enabled selinux, you must execute the following command, otherwise the system will not start properly: touch /.autorelabel. Then execute the command exec / sbin / init to start normally, or with the command exec / sbin / reboot restart on OK. If the selinux not enabled to boot directly off the line

Guess you like

Origin blog.csdn.net/lz6363/article/details/90579436