Recently in the Karst teacher's "Progressive Linux", one of which forgot the Linux root password processing method, summed up the CentOS6, 7 of the processing method, the book is described in very detailed, the following operations are in accordance with the contents of the book Step-by-step processing
CentOS6 Processing Method:
The following operation uses CentOS6.5
(1) Start the system, and when the Linux system boots to the Grub boot menu, press ESC, such as selecting the Boot key
650) this.width=650; "src=" https://s5.51cto.com/wyfs02/M00/8C/B1/wKiom1h0i5nT4gdlAABNOIe0B5Q038.jpg "title=" 1.jpg "alt=" Wkiom1h0i5nt4gdlaabnoie0b5q038.jpg "/>
(2) After selecting the system boot kernel, press the E key to enter the editing state, such as
650) this.width=650; "src=" https://s3.51cto.com/wyfs02/M02/8C/AE/wKioL1h0jAGQMVRsAAA05q8lZoM770.jpg "title=" 2.jpg "alt=" Wkiol1h0jagqmvrsaaa05q8lzom770.jpg "/>
(3) Select a line with the kernel directive, press the E key, edit the line, add a space at the end, and
650) this.width=650; "src=" https://s1.51cto.com/wyfs02/M00/8C/AE/wKioL1h0jLbghjvGAACPLenD8xA457.jpg "title=" 3.jpg "alt=" Wkiol1h0jlbghjvgaacplend8xa457.jpg "/>
(4) After the modification is complete, press ENTER to return to the previous interface.
(5) Press the B key, the system starts to boot
(6) The system for single-user mode, only enable basic services, enter passwd set a new root password, type init 3 restart into multiuser mode. Sign in with the new password.
CentOS7 Processing Method:
The following operation uses CentOS7.2
Because 7 and 6 adopt different guidance methods, the method is different. (7 is grub26 is grub)
(1) Start the system, to grub2 boot menu, find the current system boot options, press the E key, such as check the boot
650) this.width=650; "src=" https://s5.51cto.com/wyfs02/M00/8C/B1/wKiom1h0jdXhJruTAAAjgj3UYDs435.jpg "title=" 4.jpg "alt=" Wkiom1h0jdxhjrutaaajgj3uyds435.jpg "/>
(2) After E, enter the following interface, page DOWN, the cursor is positioned to the kernel boot line, after UTF-8 add the following content
650) this.width=650; "src=" https://s5.51cto.com/wyfs02/M01/8C/B1/wKiom1h0jzqibBdOAAFN7ovXUv8520.jpg "title=" 5.jpg "alt=" Wkiom1h0jzqibbdoaafn7ovxuv8520.jpg "/>
(3) Add complete, press ctrl+x, start shell boot, enter single user mode
(4) Mount the root partition as read-write mode, execute the following command
(5) If SELinux is turned on in the system, you will also need to create a Autorelabel file in the root partition or the system will not start normally
(6) Execute passwd set the new root password, after the password modification is completed, the direct execution of the reboot restart command is invalid, you need to enter the full path command
Exec/sbin/init Or Exec/sbin/reboot |
(4, 5, 6) Diagram:
650) this.width=650; "src=" https://s2.51cto.com/wyfs02/M00/8C/B1/wKiom1h0kQCCnQcbAABrAGVHg9A030.jpg "title=" 7.jpg "alt=" Wkiom1h0kqccnqcbaabragvhg9a030.jpg "/>
This article is from the "Zhao Dongwei blog" blog, make sure to keep this source http://zhaodongwei.blog.51cto.com/4233742/1890746
CentOS forgot root password