Solution after losing Linux root password

1. Restart the machine in this machine. When the grub screen appears, use the up and down keys to select the item you normally want to start linux (do not select DOS), then press the e key.

2. Use the up and down keys again to select the one you normally want to start linux (similar to kernel /boot/vmlinuz-2.6.9-42.EL ro root=LABEL=/1), then press the e key

3. Modify the command line you see now, add a space at the end of the line, type single, like this: kernel /boot/vmlinuz-2.6.9-42.EL ro root=LABEL=/1 single

4. After modification, press the “Enter” key to return to the original interface.

5. Press the letter “b” to start the boot. In this way, you can start the single-user mode of linux, which is similar to the security mode of windows. It only starts the most basic system, and network services and system services are not started. After the single-user mode is completed, there will be a # prompt, indicating that you have superuser privileges, and then execute the command after #: /usr/bin/passwd The system should prompt for a password. This password is not echoed. The input can be correct. After the carriage return, the system will ask for another input, the input requirements are the same, and then you will see the password modification success.

6. reboot and log in with your new password

Leave a Reply

Your email address will not be published. Required fields are marked *