Linux Forgot Password Solution


Many friends often forget the root password of the Linux system. What should I do if the Linux system forgets the root password? Reinstall the system? Of course not! Enter single-user mode and change the root password.

The steps are as follows:

Restart the linux system

4_21.png

Press Enter within 3 seconds, and the following interface will appear

4_22.png

Then enter e

4_23.png

#Enter single at the end of the second line, there is a space. The specific method is to press the downward tip to move to the second line, press "e" to enter the editing mode

4_24.pngAdd single at the end and press Enter

4_25.png

Finally press "b" to start, and you will enter single-user mode after startup

4_26.png

You have entered single-user mode at this time, and you can change the root password. The command to change the password is passwd

4_27.png


##【

Use the rescue mode of the system installation CD

Rescue mode is rescue. This mode is mainly used when the system cannot be entered. For example, grub is damaged or a certain configuration file is modified incorrectly. How to use rescue mode?

CD boot, press F5 to enter rescue mode

4_28.png

Enter linux rescue and press Enter

4_29.png

Select Language, the author recommends that you choose English

4_30.png

Select us keyboard

4_31.png

4_32.png## here Ask you whether to enable the network. Sometimes you may be able to debug online. We choose no

4_33.png# here tells us that the system will be mounted in /mnt/sysimage.

There are three options:

  • Continue is to continue to the next step after mounting.

  • Read-Only Mount as read-only, which is safer. Sometimes when the file system is damaged, read-only mode will prevent further damage to the file system.

  • Skip does not mount and enters a command window mode.

Here we choose Continue.

4_34.png

At this point, the system has been mounted to /mnt/sysimage. Next press Enter and enter chroot /mnt/sysimage to enter the administrator environment.

4_35.png

Tips: In fact, you can also change the root password in rescue mode. This rescue mode is very similar to the windows PE system.

After running chroot /mnt/sysimage/, and then ls, you will see that the directory structure is the same as the directory structure in the original system.

Yes! The current environment is exactly the same as that of the original system. You can type exit or press Ctrl + D to exit this environment. Then you take a look at ls

4_36.png

This directory is actually the directory structure in rescue mode, and all our system files are in the /mnt/sysimage directory.