Restore root password loss under SlackWareLinux

Source: Internet
Author: User
& Nbsp; everyone may lose something. what should I do if I lose the root password of my server? It doesn't matter. We use the following method to restore. Method 1: Use lilo to set init/bin/bash to change the password. Method 2: Start the disk, Mount/partition, and modify the/etc/shadow file.  

Everyone may lose something. what if I lose the root password of my server? It doesn't matter. We use the following method to restore.

Recovery Method

Method 1: Use lilo to set init = "/bin/bash to start and change the password.

Method 2: Start the disk, Mount/partition, and modify the/etc/shadow file to clear the password.

Method 1 implementation process

Start linux first. When lilo appears, let lilo stop with one click (do not press enter). at this time, a screen similar to the following will appear.

Here we can see that there is only one system in the lilo list, that is, the system with the startup item named slack.

Run the following command to start the system:

Slack init =/bin/bash rw

Note: the slack in the above command corresponds to the startup item name. The name of the system you set in your lilo is replaced by the name you set.

After the system enters the system, the following prompt appears:

Bash-3.00 #

Enter

Passwd

Follow the instructions given to enter a new password two to three times.

Because the current system is only a very small kernel system, we should not do any other operations, nor exit shell with exit.

After the password is changed, run the following command to read the/directory:

Mount-o remount, rw/

Now you can safely restart the system.

Method 2 implementation process

We use the slackware installation disc to start the system.

Note: If you are using a scsi hard disk, use the scsi. s parameter to start the system.

After using root to enter the boot system of this CD, we mount the linux/partition on our hard disk.

Use the following command to mount

Mkdir/mnt/root

Mount/dev/sda1/mnt/root

Note: my hard disk is scsi and the/partition is on the sda device. Therefore, I use mount/dev/sda1 to mount/partition. Your hard disk and partition may be different from mine. you need to modify the mount command on your own.

Then we use vi to edit the shadow file on the hard disk.

Vi/mnt/root/etc/shadow

We will see a picture similar to the following.

Modify the content of the first line as follows:

Root: 12941: 0 :::::

In fact, the content between the first colon and the second colon after the root is deleted. Then, save and exit, and restart the system with reboot.

Summary

The first method is not to use a CD, which is easy. You can also change the password. However, if the lilo startup screen does not appear, it will not be easy.

In SlackWare Linux, the second method of restoring the root password requires a CD to start the system, which is more complex. But it can be used as a supplement when there is no lilo startup screen. However, the second method can only simply clear the password. remember to set the password after the next startup.

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.