2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
Operating environment: Centos7.6
First, we need to restart the system and enter the boot menu interface. Here, we can see the system kernel version and boot parameters and other information. We need to press the e key to enter the edit mode and modify the boot parameters.
After entering the edit mode, use the arrow keys to move the cursor and find the line that starts with Linux. This line contains the system kernel and boot parameters. We need to replace ro in this line with rw init=/sysroot/bin/sh, so that the system can mount the root partition in read-write mode and execute the /sysroot/bin/sh script. After the modification is completed, press Ctrl+x to save and exit the edit mode. The system will start according to the parameters we modified.
before fixing:
After modification:
After the modification is completed, press ctrl+x to start the system
Here, we need to run the command chroot /sysroot/ to set the /sysroot directory as the root directory and switch back to the centos system. Then, we can run the command LANG=en to set the language to English for easy password entry. Next, we can run the command passwd to change the root password. In the process of changing the password, we need to enter the new password twice and pay attention to the complexity and length of the password.
After changing the password, we need to run the touch /.autorelabel command to create an .autorelabel file in the root directory. This will allow SELinux to relabel the security attributes of the file to avoid permission issues.
After the operation is completed, press exit to exit the environment, enter reboot to restart the system, and log in to root with the newly set password.