The following column centos system tutorial will introduce to you how to deal with forgotten root password in CentOS7. I hope it will be helpful to friends in need!
CentOS7 forgot the root password (effective in practice).
If you find that it is invalid during the operation, check if the small keyboard is not turned on when you change the password. Because of this, I once suspected that the process was wrong, because I configured it in the virtual machine, so the small keyboard The keyboard must be turned on manually every time.
Steps
1. Start the system, press the E key on the GRUB2 boot screen, and edit the boot entry
2. Delete The rhgb and quiet parameters at the end of the linux16 line (in UEFI systems are linuxefi), delete these two parameters rhgb and quiet to display system information
3. Add the following parameters: rd .break enforcing=0
In the 64-bit IBM Power Series, it is the end of the line linux; in the system booted by x86-64 BIOS, it is the end of the line linux16; in the system booted by UEFI, it is the end of the line linuxefi
4. Press CTRL Password because the file system is not writable. Remount the file system as writable.
6. The file system is remounted as writable, change the root of the file system as follows
chroot /sysroot
8. Updating the password file will cause an SELinux security context file error. Type the following command to re-label all files before the next system boot:
touch /.autorelabel9. Remount the system as read-only:
mount -o remount,ro /
10. Type the exit command to exit the chroot environment:
11. Type the exit command again to complete the initialization and complete the system boot.
exit
At this point, the password has been changed successfully. After completing the last step of exit, you will wait a little longer, and then you will enter the startup page and enter the password of the root user and you can log in successfully.
The above is the detailed content of How to solve the problem of forgetting root password in CentOS7. For more information, please follow other related articles on the PHP Chinese website!