Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Linux Forgot Password Solution

Linux Forgot Password Solution

Many people often forget the root password of the Linux system. What should you do if you forget the root password in Linux? Reinstall the system? Of course not! Just 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 appears

Then type e

At the end of the second line, type single (with a space). The specific method is to press the down arrow to move to the second line, then press "e" to enter edit mode

Add single at the end and press Enter

Finally press "b" to boot; after booting you enter single-user mode

You are now in single-user mode and can change the root password. The command to change the password is passwd

【Using the rescue mode of the system installation CD】

Rescue mode is rescue; this mode is mainly used when the system cannot boot, for example, when grub is damaged or a configuration file is modified incorrectly. How do you use rescue mode?

Boot from the CD, press F5 to enter rescue mode

Type linux rescue and press Enter

Select a language; the author recommends choosing English

Select the us keyboard

Here it asks whether to start the network; sometimes you may need network debugging. We choose no

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

There are three options:

Here we choose Continue.

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

Tip: 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/, then ls shows the directory structure is the same as the original system's directory structure.

That's right! The current environment is exactly the same as the original system's environment. You can type exit or press Ctrl + D to leave this environment. Then type ls again to take a look.

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