This article comes from Chinaunix blog, if you look at the original point: http://blog.chinaunix.net/u/22713/showart_166207.html
Today, I installed Debian to do Linux system programming, and then forgot the root password after loading it. Decisively into the single-player mode to change the password, the result needs to enter the root password.
Google solutions to solve problems, now put Google's solution to prepare for a rainy days
Now we generally use GRUB as the boot program for the system, and Lilo's approach to single-user is simple, and not mentioned here.
For some versions of the OS (for example, Redhat), edit grub, followed by "single", to go into one-user mode. For Debian, however, this approach is not valid because Debian enters single-user mode and requires you to enter the root user's password.
Here's a way to use the grub on all versions of Linux:
1. On the Grub Boot loader menu, select the entry you want to enter, and type "E" to enter edit mode.
2, in the second line (similar to kernel/vmlinuz-2.6.15 ro root=/dev/hda2), type "E" into the editing mode;
3, add "Init=/bin/bash" at the end of sentence, enter;
4, press "B" to start the system.
So we can get a bash shell.
After entering the shell, the mount mode of the root partition is read-only by default, we will change it to writable, otherwise the root password cannot be changed:
Mount-no REMOUNT,RW/
passwd Root
Sync
Mount-no Remount,ro/
Reboot
This will successfully change the Debian root user's password.