Situation description:
When we forget Linux
the root
password, how to reset root
the password?
Mine is Centos7.9
the version.
Start the server
Start the interface, press the up and down keys, select the first one, and then press e
.
Enter the editing page
Use the up, down, left, and right keys to move the cursor to the red box in the figure, which is LANG=en_US.UTF-8
the back
, and then input: init=/bin/sh
. Then, press Ctrl+x
Execute Command.
Enter, 单用户模式
after entering this mode, the following is the command line. Enter the command and Enter
execute it .
Enter the commands one by one and press Enter to execute:
mount -o remount,rw /
passwd
After entering the new password,
touch /.autorelabel
exec /sbin/init
it takes a long time to enter the process, about a few minutes.
The system automatically restarts and enters the login page.
Use the password you just set to log in root
.