Three solutions for CentOS 7 forgotten password: Single-user mode: Restart the system, edit the kernel options, change ro to rw init=/sysroot/bin/sh, and use the passwd command to reset the root password. Rescue mode: Boot from the installation media, select rescue mode, mount the root file system, chroot to the root file system, and use the passwd command to reset the root password. Grub2 command line: Restart the system, press c to enter the command line, load the kernel, mount the root file system, chroot to the root file system, and use the passwd command to reset the root password.
Forgetting your password is frustrating, but for CentOS 7 users, there are several There are several ways to retrieve your password.
Steps:
e
to edit the kernel boot options. linux16
and change ro
to rw init=/sysroot/bin/sh
. F10
to start the system.
#. passwd
. Enter
. exit
to restart the system. Steps:
mount /dev/sda1 /mnt
(Adjust according to the actual root partition). chroot /mnt
. exit
to exit the chroot environment. umount /mnt
. Steps:
c
to enter the command line. linux16 /vmlinuz initrd16 initrd.img
. mount /dev/sda1 /mnt
(Adjust according to the actual root partition). chroot /mnt
. exit
to exit the chroot environment. reboot
to restart the system. The above methods can help you retrieve your CentOS 7 password if you forget it. If you encounter any problems, please consult a professional system administrator or refer to the official CentOS documentation.
The above is the detailed content of What should I do if I forget my centos7 password?. For more information, please follow other related articles on the PHP Chinese website!