rhel7 restore root password rhel6 recover root password
1. To restore the root password of rhel7 ,
first close SELINUX
and then restart, press the ↑↓ key to enter the following interface, select the first item, and press the e key to edit. Find the ro item
on this interface, and modify it to rw init= After changing /sysroot/bin/sh
, press Ctrl+X to enter emergency mode
Principle: start a shell environment, the system does not really start
Change
the root, change the password chroot command is used to run the command
chroot in the specified root directory, That is, change root directory. In the Linux system, the default directory structure of the system starts with /, that is, the root (root). After using chroot, the directory structure of the system will take the specified location as / location
. After the chroot command, the directories and files read by the system will not be under the old system root but under the new root (that is, the specified new location) directory structure and files,
execute passwd
how to change the password before the system has selinux enabled, you must run the following command, otherwise the system will not be able to start normally:
touch /.autorelabel to
restart the system
to exit the current root first, execute /bin/sh shutdown –r now
2.rhel6 restore the root password
Press the up and down keys to stay in this interface and press lowercase e to edit
Press lowercase e to edit
Enter space 1 to enter single-user mode
Enter -->b
and then enter passwd to reset the password for root