CentOS 7/rhel 7:reset/recover Forgotten root password

Source: Internet
Author: User

CentOS 7/rhel 7:reset/recover Forgotten root password

October, by Sharad Chhetri 4 Comments

In this post we'll learn, how to reset/recover forgotten root password on CentOS 7/rhel 7 (Red Hat Enterprise Linux 7). On RHEL 5/6 or CentOS 5/6 series, the method of resetting forgotten root password was same. In latest RHEL 7/centos 7 This time we had found some difference in steps to reset the forgotten root password.

650) this.width=650; "src=" https://www.cloudways.com/affiliate/accounts/default1/banners/e609b8b4.jpg "title=" " Width= "468" height= "style=" Border:0px;height:auto "/>650" this.width=650; "src=" http://www.cloudways.com/ Affiliate/scripts/imp.php?id=28869&a_bid=e609b8b4 "width=" 1 "height=" 1 "style=" Border:0px;height:auto; "/>

Earlier, root password were used to recover from runlevel on case the boot loader password are not set.

Reset/recover forgotten root password on CentOS 7/rhel 7

Follow the given below procedure to reset forgotten root password.

Step 1:reboot or start the system, edit GRUB2

Restart/start the system and on getting GRUB 2 boot screens, first press key so, screen ESC get stopped. Then press e key for editing.

650) this.width=650; "Src=" http://i0.wp.com/sharadchhetri.com/wp-content/uploads/2014/10/vbox-1.png?resize=1315% 2c742 "alt=" vbox-1 "class=" AlignCenter size-full wp-image-5551 "width=" + "height=" 423 "style=" Border:0px;height: auto;margin:0px auto 24px; "/>

Step 2:initialize the/bin/sh

Now-in next-screen, scroll-down with the "Help" arrow key and search for any of these-keyword linux16 or on linuxefi UEFI Systems. We have linux16.

Disable RHGB and quiet parameters in order to enable system messages.

in First screenshot You can see, we first scrolldown to line starting with keyword Calledlinux16  . Now remove the Parameter RHGB  and  quiet   .

650) this.width=650; "Src=" Http://i0.wp.com/sharadchhetri.com/wp-content/uploads/2014/10/root-passwd-2.png? resize=1313%2c746 "alt=" root-passwd-2 "class=" AlignCenter size-full wp-image-5552 "width=" + "height=" 426 "style=" border:0px;height:auto;margin:0px auto 24px; "/>

In second screenshot you can see, we have removed the rhgb and quiet parameter
ADD the below given parameter at the end of line, to initialize the SH shell.

Init=/bin/sh

Now press CTRL with x keyword to boot the system.

650) this.width=650; "Src=" Http://i0.wp.com/sharadchhetri.com/wp-content/uploads/2014/10/root-password-3.png? resize=1315%2c746 "alt=" root-password-3 "class=" AlignCenter size-full wp-image-5558 "width=" + "height=" 425 "style=" border:0px;height:auto;margin:0px auto 24px; "/>

Step 3:remount/root partition, reset root password and autorelable

The filesystem would be in read only mode, hence run the below given command so, can write on filesystem

Mount-o remount, RW/

Now reset root password with given below command

passwd Root

Reconfirm the root password.

Note: In case system was not writable, the passwd tool fails with the following error:
Authentication token manipulation error

Now run the below given command for relabeling the SELINUX

Touch/.autorelabel

Now restart the system. You can use any one of the command.

Exec/sbin/init

OR

Exec/sbin/reboot

650) this.width=650; "Src=" http://i0.wp.com/sharadchhetri.com/wp-content/uploads/2014/10/vbox-6.png?resize=1320% 2c746 "alt=" vbox-6 "class=" AlignCenter size-full wp-image-5553 "width=" + "height=" 424 "style=" Border:0px;height: auto;margin:0px auto 24px; "/>

you would see the system was going to reboot and stuck for a short time. Just wait for a few seconds or minute. Keep pay attention then the screen was stopped when Seliux relabeling info message appeared on screen.
After a few moment, you'll see on the bottom of screen some numerical percentage are running. It states about the completion of SELinux relabeling in percentage. After completing 100%, the system would be rebooted.

650) this.width=650; "Src=" http://i2.wp.com/sharadchhetri.com/wp-content/uploads/2014/10/vbox-7.png?resize=1316% 2c744 "alt=" vbox-7 "class=" AlignCenter size-full wp-image-5554 "width=" + "height=" 424 "style=" Border:0px;height: auto;margin:0px auto 24px; "/>

After successful booting, you can use the your new root password for login to system.

650) this.width=650; "Src=" http://i1.wp.com/sharadchhetri.com/wp-content/uploads/2014/10/vbox-8.png?resize=1317% 2c744 "alt=" vbox-8 "class=" AlignCenter size-full wp-image-5555 "width=" + "height=" 424 "style=" Border:0px;height: auto;margin:0px auto 24px; "/>


This article from "Vincent" blog, declined reprint!

CentOS 7/rhel 7:reset/recover Forgotten root password

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.