How to restore user passwords in Linux

Source: Internet
Author: User

There are many reasons that may result in the loss of user passwords, which may not be a problem for the system administrator. You only need to log on with the root account and use the passwd command to change the user password. But what if the root password is lost? Is there no way to reinstall the system? This not only takes time and effort, but also may cause loss of important data and damage to applications. Obviously, this approach is not desirable.
In fact, restoring the Linux Password is not very difficult. There are two ways to restore the Linux Password: one is to generate a new password for the user, so that the user can log on to the system again; the other is to find the user's original password, instead of replacing the old password with a new password. Generally, users only want to log on to the system again, instead of obtaining the original password, which is the first aspect mentioned here. This aspect is relatively easy to implement. We know that Linux has two boot programs: LILO and GRUB, and the password recovery methods are also different.
Start with LILO. When the lilo: interface appears, press Ctrl + x to enter the command line mode and enter linux 1 at the boot: prompt to enter the single-user maintenance mode, in single-user mode, the system runs in the only user-root user mode. When the system enters this mode, the system only loads the minimum software and hardware configurations that can run, and directly enters the system as root, no password verification. Use the passwd root command to change the root password, or directly use the passwd-d root command to clear the root password. After reboot logs on to the system again, you do not need to enter the password. If GRUB boot is used, when the boot interface appears, press the e key, use the up and down keys to select the one you usually start linux (similar to kernel/boot/vmlinuz-2.4.20-8 ro root = LABEL =/), and then press the e key to modify the command line you see now, the result is as follows:
Kernel/boot/vmlinuz-2.4.20-8 ro root = LABEL =/single, press enter to return, and then press the B key to start, you can directly enter the linux Command Line, use the command passwd root to modify the root password, you can also directly run the passwd-d root command to clear the root password. After reboot logs on to the system again, you do not need to enter the password.
At present, many users have installed Windows and Linux systems. When windows is re-installed due to a problem, grub in MBR will be damaged and the system cannot be booted. In this case, grub needs to be restored. The repair procedure is as follows:
A. Place the first installation disc of linux to the optical drive, restart the machine, and use the optical drive to guide the system in BOIS.
B. After the installation interface is installed, press the [F5] key, that is, the linux rescue mode.
C. Enter linux rescue to enter the rescue mode;
D. Then the prompt will appear:
# Chroot/mnt/sysimage change your root directory
E. We can operate GRUB. Enter grub:
Sh # grub
The following prompt appears:
Grub>
After such a character, we can enter:

grub>root (hdX,Y)grub>setup (hd0)
If it succeeds, there will be a successful ......
X here, if it is a disk, It is 0. If the root partition of the linux installation is on the second hard disk, X is 1; Y, is the root partition where the linux system is installed. Setup (hd0) is to write GRUB to the hard disk MBR. Restart the system again. OK, the familiar GRUB boot interface is displayed again.

Related Articles]

  • Linux security overview
  • Linux security
  • Experience in ten Linux security management skills

Related Article

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.