Home > Operation and Maintenance > CentOS > How to solve the problem of forgetting root password in CentOS7

How to solve the problem of forgetting root password in CentOS7

藏色散人
Release: 2020-07-11 16:21:18
forward
3116 people have browsed it

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!

How to solve the problem of forgetting root password in CentOS7

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.

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 an SELinux security context file error. Type the following command to re-label all files before the next system boot:

touch /.autorelabel

9. Remount the system as read-only:
mount -o remount,ro /


10. Type the 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.

For more centos related technical articles, please visit the

centos basic tutorial

column!

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!

Related labels:
source:csdn.net
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