Password reset for Huawei Euler system forgot password

1. Enter GRUB boot menu edit mode

Start openEuler, when the startup screen appears, press the letter E
In the Linux system, press the "e" key after pressing the boot button to enter the GRUB boot menu editing mode. GRUB is the boot loader of the Linux system, which is responsible for loading the operating system and starting the system. In edit mode, you can modify the boot options in the GRUB boot menu, such as modifying kernel parameters, adding or deleting boot parameters, etc. This is useful for troubleshooting startup issues, debugging the system, or doing other advanced configurations. After editing, you can press Ctrl+X to launch the modified boot options. Please note that these modifications will only take effect at this startup, and will revert to the default settings after restarting.
insert image description here
After pressing the letter E, the following screen appears
insert image description here

2. Specify the system to use /bin/sh as the initialization process at startup

Move the cursor up and down to find the position of the red box, enter: init=/bin/sh, and then press the key combination CTRL+X to start

In the Linux startup item, the function of init=/bin/sh is to specify that the system uses /bin/sh as the initialization process at startup. /bin/sh is a common Unix shell, which is a command-line interpreter used to execute commands and scripts entered by the user.

By adding init=/bin/sh to the startup items, the system will go directly to the command line interface at startup without performing other initialization processes. This is very useful for system troubleshooting and maintenance as it allows users to get a clean command line environment at system startup for diagnostic and repair operations.

It should be noted that starting the system with init=/bin/sh may bypass some normal boot procedures and security mechanisms, so it should be used with caution and only when necessary.

insert image description here
insert image description here
insert image description here

3. Change password

3.1 Remount the file system to make the file system writable

mount -o remount,rw /

This command is used to remount the file system and mount it as read-write. Specifically, the -o remount,rw option means to remount the file system and mount it in a read-write manner. / indicates the root directory of the file system to be remounted. By executing this command, you can write on a file system mounted in read-only mode.
insert image description here

3.2 Change password

Enter the command:

passwd

insert image description here
Enter a new password: for example, openeuler21.09, you need to enter twice to confirm
insert image description here

3.3 Relabeling the security context of a file

input the command:

touch /.autorelabel
exit

The touch command is used to create a new empty file, or to update the access and modification times of an existing file. /.autorelabel is a file path, which means to create a file named .autorelabel in the root directory. In some Linux distributions, this file is used to automatically relabel the security context of the file at system startup. The security context of a file is relabeled to ensure the security and integrity of the file.
insert image description here
After exit, use the power button directly to "shut down".

4. Turn on the computer and enter the modified password to log in normally

insert image description here
Reference: https://blog.csdn.net/xcjyxy2021/article/details/123341648

Guess you like

Origin blog.csdn.net/wyw0000/article/details/132075202