Root Password loss Solution

Source: Internet
Author: User
Article Title: root Password loss solution. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Some friends often forget the root password after setting linux! Do you want to reinstall it? The answer is no ~.

Generally, there are two ways to change the root password:

1. Change the password in single-user mode
For lilo, enter

Code:
Boot: linux single

For grub, enter "e" at startup to edit the startup item, and add "single" at the end of the "kernel xxx" line"

Code:
Kernel/boot/lfskernel-2.6.8.1 root =/dev/hda2 ro single

After starting, the root user will not prompt the password. Enter passwd to reset the password.

However, there are some special init methods that may make this method less smooth, such as the following prompt (or other strange information ):

Code:
Give root password for maintenance
(Or type Control-D for normal startup)

So we need to directly use bash instead of the system's init:

Code:
# For lilo:
Boot: linux init =/bin/bash
For grub:
Kernel/boot/lfskernel-2.6.8.1 root =/dev/hda2 ro init =/bin/bash

After startup, you will get a root shell, but the hard disk is read-only and needs to be reloaded:

Code:
# Mount-o remount, rw/
... Do what you want to do, such as vi/etc/passwd ....
# Mount-o remount, ro/

You can restart it.

2. Load the system partition and change the password (applicable to password-protected startup Manager)

You can use other linux LiveCD (such as the rescue mode of the Knoppix and RedHat installation disks) to start and load the partition where the system is located:

Code:
Mount/dev/hda2/mnt

Then, modify/mnt/etc/passwd and clear the password.

Or

Code:
Chroot/mnt
Passwd

Set new password

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.