YouTip LogoYouTip

Linux Forget Password

# Linux Forgot Password Solution Many friends often forget the root password of the Linux system. What should you do if you forget the root password in a Linux system? 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 will appear !(#) Then type 'e' !(#) At the end of the second line, type 'single' with a space. The specific method is to use the down arrow key to move to the second line, press "e" to enter edit mode !(#) Add 'single' at the end and press Enter !(#) Finally, press "b" to start. After starting, you will enter single-user mode !(#) At this point, you have entered single-user mode, and you can change the root password. The command to change the password is 'passwd' !(#) **** Rescue mode is mainly used when the system cannot be booted. For example, if GRUB is corrupted or a configuration file is modified incorrectly. How to use rescue mode? Boot from the disc, press F5 to enter rescue mode !(#) Type 'linux rescue' and press Enter !(#) Select the language. I suggest you choose English !(#) Select the US keyboard !(#) !(#) Here it asks if you want to start the network. Sometimes you might need to connect to the network for debugging. We choose 'No' !(#) Here it tells us that the system will be mounted in /mnt/sysimage next. There are three options: * Continue: Mount and proceed to the next step. * Read-Only: Mount as read-only, which is safer. Sometimes, if the file system is damaged, read-only mode can prevent further damage. * Skip: Do not mount, and enter a command-line mode. 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/', if you type 'ls', you will see that the directory structure is the same as in the original system. 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 exit this environment. Then type 'ls' again to see !(#) This directory is actually the directory structure under rescue mode, while all our system files are in the /mnt/sysimage directory.
← Linux Remote LoginLinux System Contents β†’