How do I forget the root password?

Source: Internet
Author: User
If you forget the root password, you are the system administrator when using your Unix or Linux system. This means that no one else will help you in case of a problem. What should I do if I forget the root password? The following describes the solutions for the Linux operating system... if you forget the root password, you are the system administrator when using your Unix or Linux system. This means that no one else will help you in case of a problem. What should I do if I forget the root password? The following describes the solutions for most modern Linux systems. I. if you have sudo permissions, you can use the following command to quickly change the root password: sudo passwd root 2. if you do not have sudo permissions, or if your system is configured to prohibit sudo from changing the root password, you will find that changing the root password requires more sophisticated measures. The general policy is to use a Linux CD to start the system and take over computer management. Then mount the Master (root) file system on the hard disk. Once this step is completed, you can use this mount point as the root of the file system, and then use the standard passwd program to change the root password. 1. boot Linux from Live CD. 2. Press Key combination to enter the command line. 3. change to Super User: sudo su 4. start partition table editor: parted (if the system does not have parted, you need to use another partition editor, such as fdisk, cfdisk, or sfdisk .) 5. display the partition information of the primary hard disk in parted: print 6. write down the name of the device that contains the hard disk of the Linux system, such as/dev/hda or/dev/sda. 7. write down the primary Linux Partition number, for example, partition number 2. If you cannot determine which is the root partition, you can view the ext3, ext2 reiserfs, or xfs file system. If there are more than one partition, write down all the numbers. 8. stop the parted program. Quit should now return a shell prompt. 9. create a mount point for the file system on the hard disk (harley in this example): mkdir/mnt/harley 10. mount the root file system on the hard disk by using the device name and partition number obtained by The parted program. For example, if the device name is/dev/hda and the partition number is 2, run the following command: mount/dev/hda2/mnt/harley, if more than one possible partition is found, select one partition. If the selected partition number is incorrect, try another one. 11. confirm that the root partition has been mounted. To test this, you can check whether the shadow File (/etc/shadow) is in this partition. The shadow file contains the required password: ls/mnt/harley/etc/shadow if there is no password file, the root partition is not mounted. Return to step (10) and try to mount another partition. Continue these two steps until the root partition is mounted successfully. 12. change the root password on the hard drive system. There are many ways to complete this step. The simplest method is to use the new Mount point as the root of the file system to run the passwd command. This requires only one simple command: chroot/mnt/charley passwd, the chroot (change root, change? Too many? Why? Ldquo; temporarily change the root of the file tree to/mnt/harley, and then execute the command passwd ." Because it is already in superuser mode, the root password will be changed by using the passwd command. And because the root of the file system has been temporarily changed to/mntharley, the password file used is the password file (/mnt/harley/etc/shadow) located on the hard disk ). In this way, you can change the root password of the system on the hard disk. 13. remove the CD, restart the system from the hard disk, and test and ensure that the password has been changed correctly.
 
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.