Debian forget Root Password solution and notes for editing sudoers

Source: Internet
Author: User

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 ......

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.