Howto reset the forgotten root password (Access single user mode) in CentOS/RHEL 7
How many times did you need to reset the root password for CentOS/RHEL 7? or How many times did you need to login to CentOS/RHEL 7 in a single user mode to perform some fixes for you Linux box?.
For me, I had to login many times, and I expect you’ll need to login in a single user mode many times also.
In this mini post I’ll show you how to login in a single user mode to do whatever you need. To do this, do the following steps:
- Click [View Console] to access the console and click the send CTRL+ALT+DEL button on the top right. Alternatively, you can also click [RESTART] to restart the server.
- As soon as the boot process starts, press ESC to bring up the GRUB boot prompt. You may need to turn the system off from the control panel and then back on to reach the GRUB boot prompt.
- You will see a GRUB boot prompt – press “e” to edit the first boot option. (If you do not see the GRUB prompt, you may need to press any key to bring it up before the machine boots)
- By using the arrow keys, find the kernel line (starts with “linux16“), change
rw init=/sysroot/bin/sh, see the following image:
- Press CTRL-X or F10 to boot single user mode.
- System will boot and you will see the root prompt. If you try to write the “passwd” command, you’ll not find it as your are in the emergency mode, check this image:
- Type “chroot /sysroot” and then “passwd” to change the root password as follow:
- Finally, reboot your CentOS/RHEL 7 server with this command “reboot -f
If You Appreciate What We Do Here On Mimastech, You Should Consider:
- Stay Connected to: Facebook | Twitter | Google+
- Support us via PayPal Donation
- Subscribe to our email newsletters.
- Tell other sysadmins / friends about Us - Share and Like our posts and services
We are thankful for your never ending support.