Howto reset the forgotten root password (Access single user mode) in CentOS/RHEL 7

undefined

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:

 

  1. 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.
  2. 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.undefined
  3. 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)
  4. By using the arrow keys, find the kernel line (starts with “linux16“), change ro to rw init=/sysroot/bin/sh , see the following image:undefined
  5. Press CTRL-X or F10 to boot single user mode.
  6. 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:undefined
  7. Type “chroot /sysroot” and then “passwd” to change the root password as follow:undefined
  8. Finally, reboot your CentOS/RHEL 7 server with this command “reboot -f".

If You Appreciate What We Do Here On Mimastech, You Should Consider:

  1. Stay Connected to: Facebook | Twitter | Google+
  2. Support us via PayPal Donation
  3. Subscribe to our email newsletters.
  4. Tell other sysadmins / friends about Us - Share and Like our posts and services

We are thankful for your never ending support.

Leave a Reply

Your email address will not be published. Required fields are marked *