Home >Operation and Maintenance >CentOS >Solution to forget root password in CentOS7
CentOS7 solution for forgetting the root password
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 (linuxefi in UEFI systems). Delete the rhgb and quiet parameters to display system information
3. Add the following parameters: rd.break enforcing=0
In 64-bit IBM Power Series, the end of the line is linux; in x86-64 BIOS booted systems in UEFI booted system is linuxefi.
4. Press CTRL X to boot the system with the changed parameters
5. When the /sysroot/ file system is mounted as read-only, you cannot change the password because the file system is not writable. Remount the file system as writable.
mount -o remount,rw /sysroot
6. The file system is remounted as writable. Change the root of the file system as follows
chroot /sysroot
7. Enter the passwd command, and then the command line prompts to change the root password
8. Updating the password file will cause SELinux security context file errors. Type the following command to re-mark all files before the next system boot:
touch /.autorelabel
9. Remount the system as read-only:
mount -o remount,ro /
10. Type exit Command to exit the chroot environment:
exit
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.
Recommended tutorial: "CentOS"
The above is the detailed content of Solution to forget root password in CentOS7. For more information, please follow other related articles on the PHP Chinese website!