en
  English
Phone:  +1 (217) 636-4164
Skype:  onegbits
  1. Home
  2. Blog
  3. How To Reset Forgotten Root Password On CentOS 7

How To Reset Forgotten Root Password On CentOS 7

How To Reset Forgotten Root Password On CentOS 7

05

Mar, 18

5918

In this tutorial we will show you How To Reset Your Forgotten Root Password On CentOS 7 Servers. You can use this simple trick to reset your forgotten root password for CentOS 7 servers. This tutorial will be handy for administrators who are locked out of their CentOS machine and can’t sign on.

Note: This trick will only work if you have direct access to the machine. Since you need boot menu access to do this trick, you can’t reset the root password if you’re remotely connected.

How To Reset Your Forgotten Root Password On CentOS 7 Servers

Step 1: To get started, turn on your machine. To select the operating system kernel to boot in, you will have 5 seconds at boot menu.

 Step 2: After booting your machine, press e to edit the existing kernel (Core) at the boot menu.

1_15

Step 3: Next, scroll down to find the line including ( ro ) . You must change that 'ro' to 'rw' and start into a bash shell.

2_12

Step 4: To start into a bash shell you must add init=/sysroot/bin/sh to this line too. The line must be like rw init=/sysroot/bin/sh as you see in the following image.

rw init=/sysroot/bin/sh

3_7

Step 5: Now, 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

4_5

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

5_3

It will ask you to create and confirm a new password.  To update SELinux parameters, after creating the password, run the commands below:

touch /.autorelabel

ُStep 6: Exit and reboot your system and login using new password.

Congratulations! You have learned How To Reset Forgotten Root Password On CentOS 7.

If you are facing any problem with the steps, fell free to comment here. We will help you to solve the issue.

Leave A Comment