How to Reset Root Password in RHEL 7
How to Reset Root Password in RHEL 7

CALL NOW FOR FREE CONSULTATION

+91 9983340133, +91 9001997175

grras

How to Reset Root Password in RHEL 7

How to Reset Root Password in RHEL 7

Setting up the root password is a mandatory part of the Red Hat Enterprise Linux 7. If you forget or lose your password, it is possible to reset it by certain steps. Now it is known as Emergency mode in RHEL 7, Previously in RHEL 5/6 it was “Single User Mode”.  In GRUB 2(For RHEL7), resetting the password is no longer performed in single-user mode as it was in GRUB included in Red Hat Enterprise Linux 6.Here we use some other method.

The root password is now required to operate in single-usermode as well as in emergency mode.

Steps for Resetting the Root Password

  1. Please follow this procedure carefully, any mistake can make your system unstable.
  2. Start the system and, on the GRUB 2 boot screen, press the e key for edit.
  3. Add the following parameter at the end of the linux line.

rd.break

        4.  Now press Ctrl+x to boot the system with the parameter. The shell prompt appears. This reboot will take you to the /sysroot folder. Here /sysroot is the place where everything is kept before it gets mounted on the / , during the Booting process, after the booting, everything is mounted on the / folder. By default the /sysroot folder is mounted with read only (ro) permissions, so in order to make the changes we have to remount /sysroot with read write permissions(rw). You will not be allowed to change the password if the file system is not writable. To remount the file system as writable, run the command:

#mount -o remount,rw  /sysroot

Now we have to change our chroot to /sysroot

#chroot /sysroot

 5.    Run the passwd command and follow the instructions displayed on the command line to change the root password. Note that if the system is not writable, the passwd tool fails with the error.

6.    Once you login into your system change the SELINUX Context of /etc/shadow file to default, because the kernel disable the SELINUX temporarily and because of the SELINUX system will not start during the next boot. To make sure that SELinux context of the files that were modified is restored properly after boot, run

#touch /.autorelabel

7.    Now for logout & reboot type following command

#exit

#exit

 

Leave a Reply

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