Home >Operation and Maintenance >CentOS >Solution to forget root password in CentOS7

Solution to forget root password in CentOS7

Guanhui
GuanhuiOriginal
2020-06-02 11:30:3011099browse

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

Solution to forget root password in CentOS7

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

Solution to forget root password in CentOS7

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.

Solution to forget root password in CentOS7

4. Press CTRL X to boot the system with the changed parameters

Solution to forget root password in CentOS7

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

Solution to forget root password in CentOS7

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 /

Solution to forget root password in CentOS7

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

Solution to forget root password in CentOS7

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn