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]
- Experience in ten Linux security management skills