What if I forgot my Linux account password?

Source: Internet
Author: User

In modern society, the need to remember the user and password is too much, are set to be the same and unsafe, on the computer or paper is not safe. Reasoning still in mind, and then led to a long time useless host forgot password. But it doesn't matter, we can use the technology to reset the password.


Here are the CentOS 6.7 examples:

I really forgot the password, but it's okay, we have a way .

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7E/20/wKiom1b35yDyvdx5AAAT1pyXDHE734.png "title=" 1.png " alt= "Wkiom1b35ydyvdx5aaat1pyxdhe734.png"/>


1. When the system loads the kernel, press "E" key to enter the grub interface.

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7E/1C/wKioL1b36NzjcX9FAAAnvn1KUQI433.png "title=" 2.png " alt= "Wkiol1b36nzjcx9faaanvn1kuqi433.png"/>


2. Press the "E" key to edit the Grub menu

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/7E/1C/wKioL1b36Y3BvYoIAAAyud8Y53Y226.png "title=" 3.png " alt= "Wkiol1b36y3bvyoiaaayud8y53y226.png"/>


3. Select "Kernel", press "ENTER", add 1, s, s or single at the back, and then OK, press "B" key to start the one-user mode

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/7E/20/wKiom1b36ezRwpWaAAAZHzcoHMY080.png "title=" 1.png " alt= "Wkiom1b36ezrwpwaaaazhzcohmy080.png"/>


then we can change the root password happily.


Why is it possible to change the password? We're going to have to get a deeper look at grub.


1. The function of Grub

(1) menu and interactive interface available

E: Edit mode, for editing menus;

C: Command mode, interactive interface;

(2) Loading the user-selected kernel or operating system

Allow parameters to be passed to the kernel

To hide this menu

(3) provides a protection mechanism for the menu

Certification for the Edit menu

To enable authentication for the kernel or operating system


2. Grub Program Phase

Stage1: bootloader in MBR

STAGE1_5:MBR sector, allowing bootloader in Stage1 to identify the filesystem on the partition where the stage2 resides

Stage2: Disk partition (/boot/grub/)


3. Grub command-line interface

Help: Get assistance list

Help KEYWORD: More information

Find (hd#,#)/path/to/somefile:

Root (hd#,#) to set Grup device

Kernel/path/to/kernel_file: Set the kernel file used in this boot, and add many cmdline parameters which the kernel supports.

For example: Init=/path/to/init, selinux=0 disables SELinux functionality in the kernel

Initrd/path/to/initramfs_file: Set the RAMDisk to provide additional files for the selected kernel;

Boot: booting the selected kernel;


In general our system is loaded with GRUB configuration information by default, and we can also start manually

To start the system manually on the GRUB command line interface:

grub> Root (hd#,#)

grub> kernel/vmlinuz-version-release ro Root=/dev/device

Grub> initrd/initramfs-version-release.img

grub> Boot


4. Configuration files

/boot/grub/grub.conf Configuration items:

default=#: Sets the default Start menu item, and the entry (title) number starts at 0;

timeout=#: Specifies the length of time the menu item waits for an option to be selected;

Splashimage= (hd#,#)/path/to/xpm_pic_file: Indicates the menu background picture file path;

Hiddenmenu: Hide menu;

Password [--MD5] STRING: Menu Editor authentication;

Title Title: Defines the menu item "title", which can appear multiple times, to boot multiple cores or operating systems

Root (hd#,#): Grub finds the device partition where the Stage2 and kernel files are located; "root" for grub;

Kernel/path/to/vmlinuz_file [PARAMETERS]: Boot kernel

initrd/path/to/initramfs_file: kernel-matched Ramfs file;

Password [--MD5] STRING: Authentication when starting the selected kernel or operating system


5. Installing Grub

(1) Grub-install install Grup on disk

Grub-install--root-directory=root/dev/disk

(2) Grub enters Grup mode directly from the command line

grub> Root (hd#,#)

grub> Setup (hd#)




So when we/boot/grub/grub.conf configuration item, set the GRUB password and start the system password, this time suddenly forgot, how should we solve it?


This time grub is not going to get in, we only use the system disk into the rescue mode. First, enter the "BIOS" settings CD-ROM priority boot.

Then choose a third, rescue mode

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/7E/20/wKiom1b38CGS3UgUAAKRylN4pVo025.png "title=" 1.png " alt= "Wkiom1b38cgs3uguaakryln4pvo025.png"/>



Click Next, and then

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7E/20/wKiom1b38JKhj60fAAA9ha_kK8o054.png "title=" 2.png " alt= "Wkiom1b38jkhj60faaa9ha_kk8o054.png"/>


and start the shell.

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7E/20/wKiom1b38jLy4qFnAAARWvLyfyQ211.png "title=" 2.png " alt= "Wkiom1b38jly4qfnaaarwvlyfyq211.png"/>


So that we can modify the configuration file at the command line, the two lines of the password, delete it ok

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7E/1D/wKioL1b381jBq27WAAAHv0b6E6A454.png "title=" 2.png " alt= "Wkiol1b381jbq27waaahv0b6e6a454.png"/>



This article is from the Linux OPS blog, so be sure to keep this source http://ch666.blog.51cto.com/10870222/1757343

What if I forgot my Linux account 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.