方方长长

方方长长

Enter single user mode in CentOS 7

  1. When starting up, enter the following interface (press the arrow keys to prevent the system from automatically continuing):
    5i1Fx.png

Press the "e" key to display the following interface:

5i7Pj.png

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:
5iN9p.png

  1. Press Ctrl-x to restart and enter single user mode.

  2. Execute "chroot /sysroot". The "chroot" command is used to switch the system, and the "/sysroot/" directory is the original system.

:/# chroot /sysroot
:/#

  1. 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.

  2. 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".

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.