Some time it happens that you forgot the root password of your centos 7.If that is the case then relax you can reset the password using the following easy step by step process.

1.Boot the centos7 serever

2.Press e to edit existing kernel (Core) 

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

3.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

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

You’ll be prompted to create and confirm a new password.  After creating the password, run the commands below to update SELinux parameters

touch /.autorelabel

Was this article helpful?

Leave a Reply

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