- When starting up, enter the following interface (press the arrow keys to prevent the system from automatically continuing):
Press the "e" key to display the following interface:
Press the down arrow key to locate to the end and find the line with "ro". "ro" means read only. Replace "ro" with "rw init=/sysroot/bin/sh" as shown in the figure below:
-
Press Ctrl-x to restart and enter single user mode.
-
Execute "chroot /sysroot". The "chroot" command is used to switch the system, and the "/sysroot/" directory is the original system.
:/# chroot /sysroot
:/#
-
If you want to change the root password, use the "passwd" command. Execute the command "touch /.autorelabel" to make SELinux effective. If not executed, the password will not take effect. Press Ctrl+D and execute "reboot" to restart and make the changes effective. See the figure below.
-
If you cannot enter the desktop due to enabling x-window or updating the graphics driver, you can modify the default startup level (boot into command line mode).
Use the command "systemctl set-default multi-user.target" to set it to command mode.
Use "init 3" to switch to character mode. Sometimes the above statement alone may not be effective.
After pressing Ctrl+D, execute "reboot".