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
Press Enter within 3 seconds, and the following interface will appear
Then enter e
#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
Add single at the end and press Enter
Finally press "b" to start, and you will enter single-user mode after startup
You have entered single-user mode at this time, and you can change the root password. The command to change the password is passwd
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 modeEnter linux rescue and press EnterSelect Language, the author recommends that you choose EnglishSelect us keyboard## here Ask you whether to enable the network. Sometimes you may be able to debug online. We choose no
# 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.
At this point, the system has been mounted to /mnt/sysimage. Next press Enter and enter chroot /mnt/sysimage to enter the administrator environment.
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
This directory is actually the directory structure in rescue mode, and all our system files are in the /mnt/sysimage directory.