Root password cracking under CentOS 7

Due to improper work handover, inadequate information recording, forgotten passwords, etc., sometimes the root administrator password is lost. At this time, we need to manually crack the root password. So what should we do? Next, let's take a look at the method to crack the password on CentOS 7

First, we power on the host normally, and when the system is booted to the boot menu item, immediately press any key to pause the startup (the system defaults to 5 seconds, if the first time is missed, restart and try again), then press e Key to enter edit mode, as shown in the figure

Move the cursor to the line starting with linux16, add the kernel parameter rd.break (preceding a space to inform grub2 that this is an independent command item) after the quiet item at the end, and then press the Ctrl + X key combination to start

After the bootloader reads the above kernel parameters, it will enter the following interface

As we know, when entering Recure Mode and Emergency Mode, the root system entered by default is a pseudo-root, and the root directory needs to be switched, so we pass mount Command first look at the current mounting situation

As we can see in the above picture, our system partition /dev/sda3 is mounted on /sysroot, so we need /dev/sda3 to partition the real system (ie /dev/sda3) Mount to /sysroot in read-write mode (rw)

mount –o remount,rw /sysroot

We use mount to confirm whether it has been remounted in read-write mode

As above, you can confirm that it has been successfully mounted.

Cut the roots. ***Attention, the shell prompt changes at this time. ***

chroot /sysroot

Reset the root password and perform the marking operation (ie SELinux security label), and the system may restart twice to complete the marking work.

After the marking is completed, enter exit twice in a row, then reboot, and you can enter the login interface after restarting.

***At this point, the root password under CentOS 7 has been successfully reset, and relevant management work can be done later. In particular, here is an additional method to crack the root password. The overall idea is the same as the above method. The main difference lies in the shell used for the recovery operation. ***

Same as method 1, boot and press the e key to enter the boot menu item of grub2, and edit the kernel command parameters. Add rw init=/sysroot/bin/sh at the end of the line starting with linux16, and then press Ctrl + X to start. Please note that when modifying the kernel command chain, this method directly declares the mount in read-write mode rw, so you can directly cut the root operation after restarting

Same as method 1, follow by cut root chroot -> reset root password -> hit the security label -> exit -> reboot


Recommended Posts

Root password cracking under CentOS 7
How to quickly modify root password under CentOS8
CentOS 7 Root user password reset
CentOS7/Redhat7 cracking Root password (linux)
Remove root password verification strategy under ubuntu
Centos7.5 expands the space size under the root directory
Deploy GitBook under CentOS7
Compile Hadoop-2.7.6 under CentOS7.4
Install mysql5.7 under CentOS7
Install ActiveMQ under Centos7
Install PostgreSQL12 under CentOS7
Install CentOS under VMware
Deploy JDK+Tomcat8 under CentOS
Install mysql under Centos 7
Configure lamp under centos6.8
CentOS7 reset MySQL8.0 password
Install Jenkins under Centos 7
Redis3 installation under Centos7
Install MariaDB under MariaDB Centos7
Install mysql5.1 under CentOS6.5
Installation and cracking of confluence6.3 operation records under Centos
Installation and cracking of Jira7 operation records under Centos
Xen virtualization combat under CentOS 6.6
[CentOS environment deployment] Java7/Java8 deployment under CentOS
Build OpenV** Server under CentOS7
Build OpenLDAP server under CentOS7
Redis cluster installation under CentOS
Install Oracle11gR2 database under CentOS6.9
3 partitioning tools under CentOS Linux
Install MySQL under Linux (CentOS 7)
Redis cluster installation under CentOS
SELinux security settings under CentOS
Install Java JDK8 under CentOS6
Install MongoDB database under CentOS7
ubuntu root default password (initial password)
CentOS 6.8 under linux install mongodb
Set static IP under Centos
Install Mesos tutorial under CentOS7
Install and configure keepalived under CentOS 5.9
Use Nginx and u under CentOS
[Introduction to redis] Install redis under Centos
RabbitMQ cluster deployment record under Centos6.9
Installation under centos6.9 of jenkins learning
Build a PXC cluster under CentOS8
Elasticsearch cluster deployment record under CentOS7
Upgrade OpenSSL and OpenSSH under CentOS7
Deploy and optimize Tomcat under Centos
Install Harbor mirror warehouse under CentOS
Build an FTP server under centos7
Java-JDK installation and configuration under CentOS
Install Python3 and ansible under CentOS8
Install the latest OpenCV4.3 under Centos8
Install and use docker under CentOS 6.8
Compile FFMPEG source code under CentOS7
Install Python3 and Py under CentOS7
Manually upgrade node version under CentOs
FFmpeg environment deployment record under centos7
Manually upgrade node version under CentOs
Erlang 20.2 installation and deployment under CentOS 7
PPTP environment deployment record under Centos
Install Mono 3.2 and Jexus 5.4 under CentOS 6.3