You can support us by downloading this article as PDF from the Link below. Download the guide as PDF

Question: How to reset root Password on CentOS 7 / RHEL 7?. I’ll take you through the steps to reset the forgotten root password on CentOS 7 / RHEL 7.

For RHEL 8 / CentOS 8, check: How to reset root password in RHEL 8

For you to be to able to reset the root password on CentOS 7 / RHEL 7 server, you need:

  • Working operating system – Only root password being unknown
  • A working GRUB boot loader

Note that CentOS 7 and RHEL 7 comes with GRUB version 2. It is not possible to reset root password in a single-user mode which was supported in RHEL 6.x and CentOS 6.x. The root password now operates in Single-User Mode and in emergency Mode.

How to reset root on CentOS 7 / RHEL 7

Use below steps to reset root password on your CentOS 7 / RHEL 7 server

How to reset root on CentOS 7 / RHEL 7: METHOD 1:

  1. Boot Up your system and on the Grub2 boot Menu screen, Press e on the Keyboard to enter.Grub Edit Mode
  2. After pressing “e“, scroll down to linux16 line and remove rhgb, quiet and LANG parameters. To easily move to the end of the line press ctrl+e and to move to the front of the line press ctrl+a. The Linux16 line will be linuxefi on the UEFI system.
  3. At the end of the linux16 line or linuxefi in case of UEFI system. Add the following line:
    rd.break 

    Full line will be similar to:

    linux16 /vmlinuz-3.10.0-327.el7.x86_64 root=/dev/mapper/centos-root \
     ro rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rd.break
  4. To boot the system with the New parameter parsed, press ctrl+x which will take you to prompt window.
  5. Mount the file system as read and write, you cannot change the password when the filesystem is not writable. Remount is as writable by typing the following command.
# mount -o remount,rw  /sysroot

 7. Chroot into the /sysroot

# chroot /sysroot

8. Now change the password

# echo password  |  passwd --stdin  root
  • Replace password with the password you wish to use
    You can Learn How to Add New User To a Linux System Here

9. Set SELinux relabeling on next boot

# touch /.autorelabel

10. Resume the initialization and resume the System by

# exit
# exit

See below picture for illustration.

reset rhel 8 root password from grub 05

How to reset root on CentOS 7 / RHEL 7: METHOD 2

1. An alternative method is to enable mount as rw. Your last line of linux16 contain:

rw init=/bin/bash

The full line will look like:

linux16 /vmlinuz-3.10.0-327.el7.x86_64 root=/dev/mapper/centos-root \
 ro rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rw init=/bin/bash

2. Press ctrl + x , you’ll be prompted with bash terminal window.

3. Now change the password

# echo password  |  passwd --stdin  root
  • Replace password with the password you wish to use

4. Set SELinux relabeling on next boot

# touch /.autorelabel

5. Resume reboot by typing exec /sbin/init to complete password reset.

# exec /sbin/init

You’ll now be able to login with your new password.

As an appreciation for the content we put out,
we would be thrilled if you support us!


As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.

LEAVE A REPLY

Please enter your comment!
Please enter your name here