RHEL7 restore root Password

Source: Internet
Author: User

RHEL7 restore root Password
Preface

I had a small game a few days ago, so I could use this knowledge. I sorted it out because I was put into trouble by the articles and tutorials I gave during the competition! So many articles are all copied one by one. How many of them are self-tested by the editors themselves! Some methods do not work at all. The results are useless if the old method is used. I am also confused. I trust the same tutorial on the Internet without studying it myself. Several days after the competition, I found a lot of articles on the Internet and tried them myself to sort out the available methods and notes. (Because there is no specific principle behind the research, we will only post the practice here .)

Restore the root password Method 1:

Rd. break method:

1. Enter the menu

PressEGo to the editing menu

2. Modify startup parameters

At the beginning of linux16EndEnterrd.breakAs shown in 1


Figure 1

3. Change the read/write status

Because the/sysroot permission is assigned after mount by default.ro=readonlyThe/sysroot/etc/shadow file cannot be modified. If you do not believe it, you can perform an experiment by yourself and you will find that the shadow file cannot be written. 2.

Mount-o remount, rw/sysroot


Figure 2

4. Change the root chroot

Chroot/sysroot

5. Modify the password of the root user

Echo "RedHat" | passwd-stdin root

6. Make SELinux take effect

Touch/. autorelabel

7. Exit the current

PressCtrl+DExit current status

8. Restart to enter the system

Reboot

Method 2:

Init =/bin/sh method:

1. Enter the menu

PressEGo to the editing menu

2. Modify startup parameters

At the beginning of linux16EndAt the end of the hoprhgb quietModifyinit=/bin/shAs shown in 3:


Figure 3





PS:rhgb quietRemove and modifyinit=/bin/sh, Although it can also enter/bin/sh, it will cause the situation in Figure 4:

Figure 4

3. Steps in the same way as method 1

Mount-o remount, rw/
Echo "RedHat" | passwd-stdin root
Touch/. autorelable
Exec/sbin/init

Method 3:

Rw =/sysroot/bin/sh method:

Same as method 2, but does not need to be deletedrhgb quiet, You only needroChangerw=/sysroot/bin/shYou can. 5:


Figure 4

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.