How to reset password for root user in CentOS7

Reboot server to the following interface.

Press key “e”

Add “init=/bin/sh” which is in the red box

Press key “Ctrl+x”, You’ll lonin the server without password
Reset password by inputing the following command
mount -o remount,rw /
passwd root
touch /.autorelabel
exec /sbin/init
Press “Enter”.

Login server by new password.

Leave a Reply