• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

UnixArena

  • Home
  • Discover DevOps Tools
  • kubernetes
  • DevOps
    • Terraform
    • Jenkins
    • Docker
    • Openshift
      • OKD
    • Ansible engine
    • Ansible Tower
      • AWX
    • Puppet
  • Cloud
    • Azure
    • AWS
    • Openstack
    • Docker
  • VMware
    • vCloud Director
    • VMware-Guests
    • Vcenter Appliance 5.5
    • vC OPS
    • VMware SDDC
    • VMware vSphere 5.x
      • vSphere Network
      • vSphere DS
      • vShield Suite
    • VMware vSphere 6.0
    • VSAN
    • VMware Free Tools
  • DevOps Instructor-led Training
  • Contact

How to reset the root password on RHEL 7 ?

April 13, 2015 By Cloud_Devops 11 Comments

This article will help you to reset the root password on Redhat enterprise Linux 7 (If you have lost it).  Unlike the previous  version of RHEL releases , REHL 7 brought special attention by bringing the lot of new features  on it.  You need to follow some special instruction on Redhat Enterprise Linux 7 to break the root password since SE-Linux is enabled by default. In RHEL 6 , if you start the system in runlevel 1 , you will get the root prompt to reset the root user password.

Here we will see that how we can recover the lost root password on RHEL 7.

1. Reboot the system .

2. In the grub menu, press escape key to prevent the system from booting. Edit the grub menu by pressing “e” .

RHEL 7  - Reset root password
RHEL 7 – Reset root password

3.Press the arrow keys to get the “linux16” line and press “end” key. This will take you to the end of the line. Here add ” rd.break  console=tty1 ”  like below. Press control-x to boot the system.

Edit the grub menu
Edit the grub menu

4.You will get the “switch-root” prompt like below.

Emergency mode RHEL 7
Emergency mode RHEL 7

5. When you boot the system using “rd.break” ,  system will be directly mounted on /sysroot in read-only mode. Let me remount it in read/write mode.

switch_root:/# mount -o remount,rw /sysroot

6. Switch into a chroot jail, where /sysroot is treated as the root of the filesystem tree.

switch_root:/# chroot /sysroot

7.Set the new root password. (please update the CMDB immediately !)

sh-4.2# passwd root
New password: 
Retype new password:
passwd:all authentication tokens updated successfully.

8.By default, SE-Linux will be enabled on RHEL7 . So create a blank file in the name of “.autorelabel” under root.

sh-4.2# touch /.autorelabel

9. Exit from the chroot jail and exit from the initramfs.

10 . System will reboot and perform a full SELinux relabel , then  reboot again.

11. once the system is rebooted, you will be able to login with new root password which you have set it .

Hope this article is informative to you .

Share it !  Comment it !  Be Sociable !!!.

Filed Under: RHEL7 Tagged With: RHEL7

Reader Interactions

Comments

  1. Bhuvi says

    June 4, 2020 at 11:49 am

    Thanks its really helpful

    Reply
  2. Phone Myint MYat Zaw says

    April 26, 2017 at 8:27 pm

    Thank u sir….
    Be graceful !!!!!!!

    Reply
  3. Manura says

    March 14, 2017 at 10:41 am

    Clear guidance. Thank you!

    Reply
  4. K venkatesh says

    November 25, 2016 at 5:33 pm

    Super Lingesh, It’s worked fine.

    Reply
  5. samarjit adhikari says

    November 15, 2016 at 9:53 am

    great help for resetting root password.

    Reply
  6. Mohammad says

    November 13, 2016 at 4:49 pm

    Great….it worked perfect for me. Thank you for sharing the info

    Reply
  7. DEVENDRAKUMAR YENNAM says

    November 11, 2016 at 10:03 am

    Simple for a first time user!! Helped me & excited to see it working! Thank you!

    Reply
  8. ALVIN CROFTS II says

    October 11, 2016 at 1:14 am

    Excellent – your awesome – Thanks!

    Reply
  9. IINHSO says

    September 19, 2016 at 5:03 pm

    easy and simple way to reset root password

    Reply
  10. Gauthem says

    July 6, 2016 at 7:35 pm

    Excellent!!
    By the time i nearly made up my mind to destroy the partition and reinstall a fresh OS. This helps me a lot. Thank you very much!!!

    Reply
  11. Noel Benjaminn says

    February 12, 2016 at 1:30 pm

    Thank You, this was of good help to me. Good One !!

    Reply

Leave a Reply Cancel reply

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

Primary Sidebar

Follow UnixArena

  • Facebook
  • LinkedIn
  • Twitter

Copyright © 2025 · UnixArena ·

Go to mobile version