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 statusBecause 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