Across mountains and rivers, there is always affection; liking and following is not enough!
[Click the card below to follow me]
Introduction
“If one day you suddenly can’t find me,remember to go to the Xilin Gol Grassland,because I am there herding cattle and horses.”
Preface
Recently, I needed to use aLinux environment to test a program, so I openedVMware Workstation Pro intending to install aLinux system, only to find that I had previously installed it while trying to deploy Oracle Database in a Linux environment, so I could use it directly.
However, the embarrassing thing is that I haven’t touchedLinux for too long,and I forgot the root account password.
After searching the entire internet, I found no detailed articles with images to solve this problem, so I recorded the following text, both as my work notes and to helpfriends who encounter this issue andsee this article.
Step 1
Restart the system and press the “Shift” or “Esc” key during boot to enter the GRUB boot interface
Select the kernel to boot and then press the “e” key to enter edit mode.

Step 2
Find the line starting with “linux”, change “ro” to “rw”, and add “init=/bin/bash” at the end of the line.
Press Ctrl+X to boot the system and enter single-user mode.
rw init=/bin/bash
Original:

Modified:

Step 3
At the bash prompt in single-user mode, use the “passwd” command to reset the password. For example, to reset the root password, type “passwd root”, then follow the prompts to enter and confirm the new password. Pay attention to the format of the new password.
passwd root
After the password reset is complete, type “exec /sbin/init” to restart the system, and you can log in with the new password.
exec /sbin/init

Verification
After the system restarts, enter the modified password for the root account to log in successfully.
Conclusion
What is learned from books is always shallow,
to truly understand this matter, one must practice!
Good night everyone, see you next time!
Core Command Explanation:
Change “ro” to “rw”:
"ro" is short for "read-only", indicating that the root filesystem is mounted in read-only mode. "rw" is short for "read-write", indicating that it is mounted in read-write mode after modification, allowing for changes to passwords and other system files.
Add “init=/bin/bash” at the end of the line:
This bypasses the system's default initialization program (usually systemd or init) and directly starts a bash shell as the initialization process, allowing access to a command line environment with root privileges without entering a password.
exec /sbin/init
exec means to replace the current shell process with a new process (instead of creating a child process). /sbin/init is the system's initialization program (usually a symlink to systemd in modern systems). After executing this command, the system will switch from the current bash temporary environment to the normal startup process, loading all system services and processes, and eventually entering the regular login interface.
So when you encounter such a charming,
handsome and productive blogger,
you might as well subscribe before you leave!
#Selected Past Articles#
| How to compress folders on Windows computers? Four free methods you won’t want to miss. |
| “All adults were once children, but few remember it.” — The Little Prince, a fairy tale book for healing adults. |
| About how I accidentally saw a website style and tried to use AI to create a Win10 interface simulation. |
| Happy Teacher’s Day to all teachers! Today I bring you a particle storm. |
| High-quality article: Tutorial on building a local personal free blog using Hexo+GitHub. |
| So useful it makes you cry! These free software are a must-install on a new computer. |
| Highly recommended! A completely free online PDF tool, and the best part is it has almost no ads. |
| Happy Teacher’s Day to all teachers! Today I bring you a 3D particle vortex animation. |
| Help! While others stockpile food, I stockpile memes, sharing those hilarious “eye-catching bag” meme images from the typhoon comment section. |
| Why use dependency injection? Is it just because of design patterns? I know about decoupling, but isn’t it simpler to directly call classes? Or there are many DLL libraries that can also achieve decoupling. |