English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Solution to Linux PasswordForget

Many friends often forget the root password of the Linux system. What should you do if you forget the root password of the Linux system? Do you need to reinstall the system? Of course not! You can change the root password by entering the single-user mode.

The steps are as follows:

Restart the Linux system

3 Press Enter within a second, and the following interface will appear

Then type 'e'

Type 'single' at the end of the second line, with a space. The specific method is to use the down arrow key to move to the second line and press 'e' to enter edit mode

Type 'single' at the end and press Enter

Finally, press 'b' to start, and after starting, you will enter the single-user mode

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

Use the rescue mode on the system installation disc

Rescue mode, or rescue, is mainly used for situations where the system cannot be entered, such as when grub is damaged or a configuration file is modified incorrectly. How to use the rescue mode?

Boot from the CD, press F5 Enter rescue mode

Enter linux rescue and press Enter

Choose language, the author recommends choosing English

Choose us keyboard

Here it asks if you want to start the network, which may be necessary for network debugging. We choose no

This tells us that the system will be mounted next/mnt/sysimage

There are three options:

  • Continue means to mount and proceed to the next step. 

  • Read-Only mounts as read-only, which is more secure. Sometimes, in case of file system damage, read-only mode can prevent further damage to the file system.

  • Skip does not mount, enter a command window mode. 

Here we choose Continue.

Up to now, the system has been mounted to/mnt/sysimage. Next, press Enter, and then input chroot /mnt/sysimage to enter the administrator environment.

Tip: Actually, you can also change the root password in rescue mode. This rescue mode is very similar to the Windows PE system.

When running chroot /mnt/sysimage/ After that, ls to see that the directory structure is the same as the directory structure in the original system.

No! The current environment is exactly the same as the original system environment. You can enter exit or press Ctrl + D to exit this environment. Then you can ls to see

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