Solution to forget root password in CentOS7

Guanhui
Release: 2020-06-02 11:30:30
Original
11034 people have browsed it

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
Copy after login

6. The file system is remounted as writable. Change the root of the file system as follows

chroot /sysroot
Copy after login

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
Copy after login

9. Remount the system as read-only:

mount -o remount,ro /
Copy after login

Solution to forget root password in CentOS7

10. Type exit Command to exit the chroot environment:

exit
Copy after login
Copy after login

11. Type the exit command again to complete the initialization and complete the system boot.

exit
Copy after login
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!