Forgot CentOS login password
- First turn on the system and hold down the esc key
-
- Press the e key to enter editing options
- Move the cursor all the way down to linux16, add LANG=en_US.UTF-8, a space at the end, and then add init=/bin/sh
- Press Ctrl+x to enter boot startup, and enter this interface after success.
- Enter the following command
- If selinux has been turned on, you need to enter the command
- Finally enter the command to restart the system
First turn on the system and hold down the esc key
Press the e key to enter editing options
Move the cursor all the way down to linux16, add LANG=en_US.UTF-8, a space at the end, and then add init=/bin/sh
(Note: There is no linux16 line in the above picture, you need to slide it with the down key)
Press Ctrl+x to enter boot startup, and enter this interface after success.
Enter the following command
Mount to the root directory and change the ro (read-only) permissions to rw (read-write)
mount -o remount, rw /
Select the user whose password you want to change. Here, select the root user to make changes. You can change it to the user you need to change.
passwd root
Enter the same new password twice
If the password entered is too simple, a warning will be prompted (BAD PASSWORD: The password fails the dictionary check - it is too simplistic/systematic). You can ignore it and continue to enter the password.
If selinux has been turned on, you need to enter the command
touch /.autorelabel
Finally enter the command to restart the system
exec /sbin/init 或者 exec /sbin/reboot