Phone :  +370 (5) 204-1903
Email: sales@1gbits.com
  1. Dedicated server
  2. Blog
  3. How To Reset Forgotten Root Password On CentOS 7

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.


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


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


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


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


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.

author img


Leave A Comment