This is from somewhere else, but I have forgotten where it is.
Many people often ask this question in the forum, and some people do not give much answers.
Take it out and use it as your notes.
Debian Root Password forgot Solution
For some versions of OS (such as RedHat), edit grub and add "single" to enter the single-user mode. However, this method is invalid for Debian, because Debian requires you to enter the root user password when entering the single-user mode.
The following describes how to use grub in all Linux Versions:
1. Boot Loading in grubProgramOn the menu, select the entry you want to enter and type "E" to enter the editing mode.
2. In the second line (similar to kernel/vmlinuz-2.6.15 Ro root =/dev/hda2), Type E to enter edit mode;
3. Add "init =/bin/bash" at the end of the sentence and press Enter;
4. Press "B" to start the system.
In this way, we can get a bash shell.
After entering the shell, the Mount mode of the root partition is read-only by default. We need to change it to writable; otherwise, the root password cannot be changed:
Mount-No remount, RW/
Passwd Root
Sync
Mount-No remount, RO/
Reboot
Notes for editing sudoers
There are several ways to edit sudoers. I usually use
Sudo Vim sudoers
The modified file will be warned to be read-only. So I was so stupid to modify the permission.
Sudo chmod A + x/etc/sudoers
Well, the trouble is that as long as you use the sudo command, there will be warning:
"The sudoers permission should be 400, and now it is XXX"
Actually, remember, after modification, use
WQ!
Force the disk to exit.
Ignoring the details can take you half a day ......