Loading

How To Reset Your Forgotten Root Password On CentOS 7 Servers

To get started, turn on the machine that you’ve forgotten the root password on. For CentOS 7 devices, you’ll be given 5 seconds at the boot menu to select the operating system kernel to boot into.

That 5 seconds is important, because allows for  admins to select different kernels or edit existing kernel parameters before booting.

 

At the boot menu, press e to edit the existing kernel (Core) as shown below.

 
 

Next, scroll down to the list until you see the line underlined below ( ro ) . What we need to do is change that ro to rw and start into a bash shell. It should look like this rw init=/sysroot/bin/sh.


 

Change the ro line to rw and add init=/sysroot/bin/sh

rw init=/sysroot/bin/sh


 

 

After changing that, press Control + X  or Ctrl + X  on your keyboard to start into single user mode using the bash shell specified above. In this mode, we’re going to change the root password.

In the single user mode, run the command as shown below

chroot /sysroot


 

 

Finally, run the commands below to change the root password.

 

 


Was this article helpful?

mood_bad Dislike 9
mood Like 0
visibility Views: 21999